Erlang Mailing Lists

Author Message

<  Yaws mailing list  ~  Is there an example for an authmod?

Guest
Posted: Fri Aug 14, 2009 8:05 pm Reply with quote
Guest
Hi, I am trying to write an authmod, and implemented the auth/2 function. However, I found that

(1) when yaws starts, it tries to call a get_header/0 function in this module
(2) if I return {false, Realm}, yaws will try to call an out/1 function in this module.

So what should I put into these two functions? And how can I force the browser to open a user name/password dialog (like when I am specifying "user=..." instead of "authmod=..." in the yaws configuration)? Is there an example authmod code somewhere that I can refer to?

Thanks very much!




Post received from mailinglist
Guest
Posted: Mon Aug 17, 2009 8:42 pm Reply with quote
Guest
Yu Di wrote:
> Hi, I am trying to write an authmod, and implemented the auth/2
> function. However, I found that
>
> (1) when yaws starts, it tries to call a get_header/0 function in this
> module
> (2) if I return {false, Realm}, yaws will try to call an out/1 function
> in this module.


We're still missing some good auth documentation. The auth code
was recently rewritten by a Fabian (at Kreditor) and he promised
to do a write-up.

Maybe this is the time - Fabian !!

/klacke

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post received from mailinglist
Guest
Posted: Tue Aug 25, 2009 6:49 pm Reply with quote
Guest
Yu Di wrote:
> Hi, I am trying to write an authmod, and implemented the auth/2
> function. However, I found that
>
> (1) when yaws starts, it tries to call a get_header/0 function in this
> module
> (2) if I return {false, Realm}, yaws will try to call an out/1 function
> in this module.
>
> So what should I put into these two functions? And how can I force the
> browser to open a user name/password dialog (like when I am specifying
> "user=..." instead of "authmod=..." in the yaws configuration)? Is there
> an example authmod code somewhere that I can refer to?
>
> Thanks very much!

Hi,

get_header/0 should return a list of auth headers. Depending on how you
set things up, the auth headers may already contain enough to challenge
for a password. If you are using a .yaws_auth file or have a server spec
in yaws.conf with a user or pam, the auth headers will at least contain
["WWW-Authenticate: Basic realm=\"", Realm, ["\"\r\n"]]. Also depending
on your setup, get_header may or may not be used (it's called when you
have an authmod value in yaws.conf or when you have a .yaws_auth file
with an authmod setting. If you see the warning "Failed to
...get_header(), one of the above happened.

Example of a minimal authmod module not depending on that auth headers
are already set. This will never authenticate since auth/2 always
returns {false, Realm}:


-module(authmod).

-export([auth/2]).
-export([out/1]).
-export([get_header/0]).


%% false will issue a "403", {false, X} will call out/1 in this module
auth(_Arg, Auth) ->
{false, Auth#auth.realm}.


%% Called when auth/2 returns {false, X}
out(_Arg) ->
[{status, 401},
{header, "WWW-Authenticate: Basic Realm=\"XXX\""}].


%% This should return a list of extra auth headers
get_header() ->
[].


Brgds,
/Anders

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum