diff options
Diffstat (limited to 'archives/extend/attachments/20140306')
3 files changed, 93 insertions, 0 deletions
diff --git a/archives/extend/attachments/20140306/24422ef2/attachment.html b/archives/extend/attachments/20140306/24422ef2/attachment.html new file mode 100644 index 00000000..62741bf1 --- /dev/null +++ b/archives/extend/attachments/20140306/24422ef2/attachment.html @@ -0,0 +1,19 @@ +<tt> +<div dir="ltr">I also found the answer to my own question: custom middleware<div><br></div><div>I just created:</div><div><br></div><div><div>� �1 -module(authentication_middleware).</div><div>� �2</div><div>� �3 -behaviour(cowboy_middleware).</div><br> +<div>� �4</div><div>� �5 -export([execute/2]).</div><div>� �6</div><div>� �7 execute(Req, Env) -></div><div>� �8</div><div>� �9 � � {Path, Req1} = cowboy_req:path(Req),</div><div>� 10</div><div>� 11 � � case Path of</div><br> +<div>� 12 � � � � <<"/login.html">> -></div><div>� 13 � � � � � � {ok, Req1, Env};</div><div>� 14 � � � � <<"/do_login">> -></div><div>� 15 � � � � � � {ok, Req1, Env};</div><br> +<div>� 16 � � � � _ -></div><div>� 17 � � � � � � case id3as_security:is_request_authenticated(Req1) of</div><div>� 18 � � � � � � � � {error, eauth, Req2} -></div><div>� 19 � � � � � � � � � � {ok, Req4} = cowboy_req:reply(303, [{<<"Location">>, <<"/login.html">>}], "", Req2),</div><br> +<div>� 20 � � � � � � � � � � {halt, Req4};</div><div>� 21 � � � � � � � � {authenticated, _Id, Req2} -></div><div>� 22 � � � � � � � � � �{ok, Req2, Env}</div><div>� 23 � � � � � � end</div><div>� 24 � � end.</div></div><br> +<div><br></div><div>And put this between the cowboy_router and cowboy_handler and life is all good.</div><div><br></div><div>-Mark</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 6, 2014 at 12:47 AM, Mark Nijhof <span dir="ltr"><<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br><br> +<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I want to create a module that basically sits between the incoming request and the http handler for that request to ensure a request is authenticated (using a cookie), if the request is not authenticated then I like to redirect to a specific login page (which should not be filtered).</div><br> +<br> +<div><br></div><div>Is this possible with Cowboy? Should I use the onrequest hook (not sure if I can force redirects from there) for that or is there a better way?</div><div><br></div><div>Cheers,</div><div><br></div><div><br> +<br> +-Mark<span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div dir="ltr">Mark Nijhof<br><div><div>t: � <a href="https://twitter.com/MarkNijhof" target="_blank">@MarkNijhof</a><br>s: �marknijhof</div><br> +</div><div><br></div></div><br> +</font></span></div></div><br> +</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Mark Nijhof<br><div><div>t: � <a href="https://twitter.com/MarkNijhof" target="_blank">@MarkNijhof</a><br>s: �marknijhof</div></div><div><br></div><br> +</div><br> +</div><br> + +</tt> diff --git a/archives/extend/attachments/20140306/6fa8fe3b/attachment.html b/archives/extend/attachments/20140306/6fa8fe3b/attachment.html new file mode 100644 index 00000000..2754a31d --- /dev/null +++ b/archives/extend/attachments/20140306/6fa8fe3b/attachment.html @@ -0,0 +1,67 @@ +<tt> +<div dir="ltr">Thank you for answer. <br>Is it common way (for OTP-based application) to store tests in `tests` subdirectory rather then in `src/tests/`?<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 6, 2014 at 4:40 PM, Loïc Hoguin <span dir="ltr"><<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br><br> +<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Tests should be in ./tests, not ./src/tests.<br><br> +<br><br> +If you put them in ./tests everything you mentioned will work.<div class=""><br><br> +<br><br> +On 03/03/2014 09:49 PM, Anton Koval' wrote:<br><br> +</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br> +Hello,<br><br> +<br><br> +I have next structure of my project:<br><br> +.<br><br> +├── deps<br><br> +│ ├── cowboy<br><br> +│ ├── cowlib<br><br> +│ ├── erlang_iconv<br><br> +│ ├── erlydtl<br><br> +│ ├── mochiweb_xpath<br><br> +│ └── ranch<br><br> +├── ebin<br><br> +│ ├── fetchers.beam<br><br> +│ ├── parsers.beam<br><br> +│ └── wasearch_sup.beam<br></div><br> +├── <a href="http://erlang.mk" target="_blank">erlang.mk</a> <<a href="http://erlang.mk" target="_blank">http://erlang.mk</a>><div><div class="h5"><br><br> +├── Makefile<br><br> +├── _rel<br><br> +│ └── ....<br><br> +├── relx<br><br> +├── relx.config<br><br> +├── src<br><br> +│ ├── fetchers.erl<br><br> +│ ├── main_handler.erl<br><br> +│ ├── parsers.erl<br><br> +│ ├── tests<br><br> +│ │ ├── parsers_SUITE_data<br><br> +│ │ ├── parsers_SUITE.erl<br><br> +│ │ ├── ....<br><br> +│ ├── wasearch_app.erl<br><br> +│ ├── wasearch.app.src<br><br> +│ └── wasearch_sup.erl<br><br> +└── templates<br><br> + └── index.dtl<br><br> +<br><br> +I would prefer to store tests not in `src` directory but rather in<br><br> +`tests` subdirectory.<br><br> +Erlang.mk README says: You can run an individual test suite by using the<br><br> +special |test_*| targets. For example if you have a common_test suite<br><br> +named |spdy| and you want to run only this suite and not the others, you<br><br> +can use the |make test_spdy| command.<br><br> +And of course `make test_parsers` returns `no rule to make target` error.<br><br> +Is there a way to run suites from custom directory with<br><br> +`make_<mod_name_with_suite>` command?<br><br> +<br><br> +<br></div></div><br> +______________________________<u></u>_________________<br><br> +Extend mailing list<br><br> +<a href="mailto:[email protected]" target="_blank">[email protected]</a><br><br> +<a href="https://lists.ninenines.eu/listinfo/extend" target="_blank">https://lists.ninenines.eu/<u></u>listinfo/extend</a><br><br> +<br><span class="HOEnZb"><font color="#888888"><br> +</font></span></blockquote><span class="HOEnZb"><font color="#888888"><br> +<br><br> +-- <br><br> +Loïc Hoguin<br><br> +<a href="http://ninenines.eu" target="_blank">http://ninenines.eu</a><br><br> +</font></span></blockquote></div><br></div><br> + +</tt> diff --git a/archives/extend/attachments/20140306/a517215b/attachment.html b/archives/extend/attachments/20140306/a517215b/attachment.html new file mode 100644 index 00000000..9f53e9df --- /dev/null +++ b/archives/extend/attachments/20140306/a517215b/attachment.html @@ -0,0 +1,7 @@ +<tt> +<div dir="ltr">Hi,<div><br></div><div>I want to create a module that basically sits between the incoming request and the http handler for that request to ensure a request is authenticated (using a cookie), if the request is not authenticated then I like to redirect to a specific login page (which should not be filtered).</div><br> +<div><br></div><div>Is this possible with Cowboy? Should I use the onrequest hook (not sure if I can force redirects from there) for that or is there a better way?</div><div><br></div><div>Cheers,</div><div><br></div><div><br> +-Mark<br clear="all"><div><br></div>-- <br><div dir="ltr">Mark Nijhof<br><div><div>t: � <a href="https://twitter.com/MarkNijhof" target="_blank">@MarkNijhof</a><br>s: �marknijhof</div></div><div><br></div></div><br> +</div></div><br> + +</tt> |