<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">=head1 NAME

Mojolicious::Plugin::DigestAuth - HTTP Digest Authentication for Mojolicious

=head1 SYNOPSIS

   use Mojolicious::Lite;

   plugin 'digest_auth';

   get '/admin/users' =&gt; sub {
       my $self = shift;
       return unless $self-&gt;digest_auth(realm =&gt; 'Thangz',
				        allow =&gt; '/some/file/htdigest_formated');

       # ...
   }

   # Setup with user-defined defaults
   plugin 'digest_auth',
	   realm =&gt; 'My Realm',
	   expires =&gt; 120,
	   algorithm =&gt; 'MD5-sess',
	   allow =&gt; { 	
	     # Will use 'My Realm'
	     sshaw =&gt; 'Ay3Br4h_!',
	     bob   =&gt; 'lovemywife'
	   };

   get '/account/edit' =&gt; sub { 
       my $self = shift;
       return unless $self-&gt;digest_auth;

       # ...
   }

   # Override some of the defaults here
   get '/' =&gt; sub { 
       my $self = shift;
       return unless $self-&gt;digest_auth(realm =&gt; 'RealmX',
				        qop   =&gt; 'auth',
				        algorithm =&gt; 'MD5,
				        allow =&gt; { 
				          RealmX =&gt; { user =&gt; 'password' }
				       });

       # ...
   }
  
   # Setup authorization for a set of of routes
   package YourApp;

   use Mojo::Base 'Mojolicious';
    
   sub startup
   {
     my $self = shift;
     $self-&gt;plugin('digest_auth');

     # ...

     my $admin = $self-&gt;digest_auth('/admin',
			     	    realm =&gt; 'Admin',
			     	    allow =&gt; '/www/auth/admin');
     
     $admin-&gt;route('/:id')-&gt;to('users#show');
     $admin-&gt;route('/edit/:id')-&gt;to('users#edit')
   }


=head1 CONFIGURATION

Options can be set globally when L&lt;&lt; loading the plugin|Mojolicious/plugin &gt;&gt;:

   plugin 'digest_auth', %options

Or locally when calling L&lt;&lt; C&lt;digest_auth&gt;|/digest_auth &gt;&gt; 

    $self-&gt;digest_auth(%options);

Local options override their global counterparts. 

Digest Authentication can be perfomed on a set of routes:

   sub startup
   {
     my $self = shift;
     $self-&gt;plugin('digest_auth');

     # ...

     my $admin = $self-&gt;digest_auth('/admin', %options);
     $admin-&gt;route('/edit/:id')-&gt;to('users#edit');
   }

Or from within an action:

   sub some_action
   {
       my $self = shift;
       return unless $self-&gt;digest_auth(realm =&gt; 'RealmX',
				        allow =&gt; { 
				          RealmX =&gt; { user =&gt; 'password' }
				       });
   }   

=head1 METHODS

=head2 digest_auth 

   $self-&gt;digest_auth(allow =&gt; { bob =&gt; 'password' });

   # or

   my $r = $self-&gt;digest_auth('/admin', allow =&gt; { bob =&gt; 'password' });
   $r-&gt;route('/new')-&gt;to('users#new');

=head3 Arguments

An optional URL prefix and/or an option hash

...more to come...

=head3 Returns

Without a URL prefix:

C&lt;1&gt; if authentication was successful, C&lt;undef&gt; otherwise. 

With a URL prefix:

An instance of L&lt;Mojolicious::Routes&gt;. Use this to define a set of actions to authenticate against. 
In this case authentication is performed via a L&lt;Mojolicious::Routes/bridge&gt;.

=head3 Errors

Will C&lt;croak&gt; if any of the options are invalid.

=head1 SEE ALSO

L&lt;Mojolicious&gt;, L&lt;Mojolicious::Plugin::BasicAuth&gt;

=head1 AUTHOR

(C) 2011 Skye Shaw (sshaw AT lucas.cis.temple.edu)

=head1 LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
</pre></body></html>