.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Catalyst::Authentication::Credential::HTTP 3pm" .TH Catalyst::Authentication::Credential::HTTP 3pm "2017-10-23" "perl v5.26.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Catalyst::Authentication::Credential::HTTP \- HTTP Basic and Digest authentication for Catalyst .SH "VERSION" .IX Header "VERSION" version 1.018 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Catalyst qw/ \& Authentication \& /; \& \& _\|_PACKAGE_\|_\->config( authentication => { \& default_realm => \*(Aqexample\*(Aq, \& realms => { \& example => { \& credential => { \& class => \*(AqHTTP\*(Aq, \& type => \*(Aqany\*(Aq, # or \*(Aqdigest\*(Aq or \*(Aqbasic\*(Aq \& password_type => \*(Aqclear\*(Aq, \& password_field => \*(Aqpassword\*(Aq \& }, \& store => { \& class => \*(AqMinimal\*(Aq, \& users => { \& Mufasa => { password => "Circle Of Life", }, \& }, \& }, \& }, \& } \& }); \& \& sub foo : Local { \& my ( $self, $c ) = @_; \& \& $c\->authenticate({}, "example"); \& # either user gets authenticated or 401 is sent \& # Note that the authentication realm sent to the client (in the \& # RFC 2617 sense) is overridden here, but this *does not* \& # effect the Catalyst::Authentication::Realm used for \& # authentication \- to do that, you need \& # $c\->authenticate({}, \*(Aqotherrealm\*(Aq) \& \& do_stuff(); \& } \& \& sub always_auth : Local { \& my ( $self, $c ) = @_; \& \& # Force authorization headers onto the response so that the user \& # is asked again for authentication, even if they successfully \& # authenticated. \& my $realm = $c\->get_auth_realm(\*(Aqexample\*(Aq); \& $realm\->credential\->authorization_required_response($c, $realm); \& } \& \& # with ACL plugin \& _\|_PACKAGE_\|_\->deny_access_unless("/path", sub { $_[0]\->authenticate }); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module lets you use \s-1HTTP\s0 authentication with Catalyst::Plugin::Authentication. Both basic and digest authentication are currently supported. .PP When authentication is required, this module sets a status of 401, and the body of the response to 'Authorization required.'. To override this and set your own content, check for the \f(CW\*(C`$c\->res\->status == 401\*(C'\fR in your \f(CW\*(C`end\*(C'\fR action, and change the body accordingly. .SS "\s-1TERMS\s0" .IX Subsection "TERMS" .IP "Nonce" 4 .IX Item "Nonce" A nonce is a one-time value sent with each digest authentication request header. The value must always be unique, so per default the last value of the nonce is kept using Catalyst::Plugin::Cache. To change this behaviour, override the \&\f(CW\*(C`store_digest_authorization_nonce\*(C'\fR and \&\f(CW\*(C`get_digest_authorization_nonce\*(C'\fR methods as shown below. .SH "METHODS" .IX Header "METHODS" .ie n .IP "new $config, $c, $realm" 4 .el .IP "new \f(CW$config\fR, \f(CW$c\fR, \f(CW$realm\fR" 4 .IX Item "new $config, $c, $realm" Simple constructor. .IP "init" 4 .IX Item "init" Validates that \f(CW$config\fR is ok. .ie n .IP "authenticate $c, $realm, \e%auth_info" 4 .el .IP "authenticate \f(CW$c\fR, \f(CW$realm\fR, \e%auth_info" 4 .IX Item "authenticate $c, $realm, %auth_info" Tries to authenticate the user, and if that fails calls \&\f(CW\*(C`authorization_required_response\*(C'\fR and detaches the current action call stack. .Sp Looks inside \f(CW\*(C`$c\->request\->headers\*(C'\fR and processes the digest and basic (badly named) authorization header. .Sp This will only try the methods set in the configuration. First digest, then basic. .Sp The \f(CW%auth_info\fR hash can contain a number of keys which control the authentication behaviour: .RS 4 .IP "realm" 4 .IX Item "realm" Sets the \s-1HTTP\s0 authentication realm presented to the client. Note this does not alter the Catalyst::Authentication::Realm object used for the authentication. .IP "domain" 4 .IX Item "domain" Array reference to domains used to build the authorization headers. .Sp This list of domains defines the protection space. If a domain \s-1URI\s0 is an absolute path (starts with /), it is relative to the root \s-1URL\s0 of the server being accessed. An absolute \s-1URI\s0 in this list may refer to a different server than the one being accessed. .Sp The client will use this list to determine the set of URIs for which the same authentication information may be sent. .Sp If this is omitted or its value is empty, the client will assume that the protection space consists of all URIs on the responding server. .Sp Therefore, if your application is not hosted at the root of this domain, and you want to prevent the authentication credentials for this application being sent to any other applications. then you should use the \fIuse_uri_for\fR configuration option, and pass a domain of \fI/\fR. .RE .RS 4 .RE .ie n .IP "authenticate_basic $c, $realm, \e%auth_info" 4 .el .IP "authenticate_basic \f(CW$c\fR, \f(CW$realm\fR, \e%auth_info" 4 .IX Item "authenticate_basic $c, $realm, %auth_info" Performs \s-1HTTP\s0 basic authentication. .ie n .IP "authenticate_digest $c, $realm, \e%auth_info" 4 .el .IP "authenticate_digest \f(CW$c\fR, \f(CW$realm\fR, \e%auth_info" 4 .IX Item "authenticate_digest $c, $realm, %auth_info" Performs \s-1HTTP\s0 digest authentication. .Sp The password_type \fBmust\fR be \fIclear\fR for digest authentication to succeed. If you do not want to store your user passwords as clear text, you may instead store the \s-1MD5\s0 digest in hex of the string \&'$username:$realm:$password'. .Sp Catalyst::Plugin::Cache is used for persistent storage of the nonce values (see \*(L"Nonce\*(R"). It must be loaded in your application, unless you override the \f(CW\*(C`store_digest_authorization_nonce\*(C'\fR and \&\f(CW\*(C`get_digest_authorization_nonce\*(C'\fR methods as shown below. .Sp Takes an additional parameter of \fIalgorithm\fR, the possible values of which are '\s-1MD5\s0' (the default) and 'MD5\-sess'. For more information about 'MD5\-sess', see section 3.2.2.2 in \s-1RFC 2617.\s0 .ie n .IP "authorization_required_response $c, $realm, \e%auth_info" 4 .el .IP "authorization_required_response \f(CW$c\fR, \f(CW$realm\fR, \e%auth_info" 4 .IX Item "authorization_required_response $c, $realm, %auth_info" Sets \f(CW\*(C`$c\->response\*(C'\fR to the correct status code, and adds the correct header to demand authentication data from the user agent. .Sp Typically used by \f(CW\*(C`authenticate\*(C'\fR, but may be invoked manually. .Sp \&\f(CW%opts\fR can contain \f(CW\*(C`domain\*(C'\fR and \f(CW\*(C`algorithm\*(C'\fR, which are used to build \&\f(CW%the\fR digest header. .ie n .IP "store_digest_authorization_nonce $c, $key, $nonce" 4 .el .IP "store_digest_authorization_nonce \f(CW$c\fR, \f(CW$key\fR, \f(CW$nonce\fR" 4 .IX Item "store_digest_authorization_nonce $c, $key, $nonce" .PD 0 .ie n .IP "get_digest_authorization_nonce $c, $key" 4 .el .IP "get_digest_authorization_nonce \f(CW$c\fR, \f(CW$key\fR" 4 .IX Item "get_digest_authorization_nonce $c, $key" .PD Set or get the \f(CW$nonce\fR object used by the digest auth mode. .Sp You may override these methods. By default they will call \f(CW\*(C`get\*(C'\fR and \f(CW\*(C`set\*(C'\fR on \&\f(CW\*(C`$c\->cache\*(C'\fR. .IP "authentication_failed" 4 .IX Item "authentication_failed" Sets the 401 response and calls \f(CW\*(C`$ctx\->detach\*(C'\fR. .SH "CONFIGURATION" .IX Header "CONFIGURATION" All configuration is stored in \f(CW\*(C`YourApp\->config(\*(AqPlugin::Authentication\*(Aq => { yourrealm => { credential => { class => \*(AqHTTP\*(Aq, %config } } }\*(C'\fR. .PP This should be a hash, and it can contain the following entries: .IP "type" 4 .IX Item "type" Can be either \f(CW\*(C`any\*(C'\fR (the default), \f(CW\*(C`basic\*(C'\fR or \f(CW\*(C`digest\*(C'\fR. .Sp This controls \f(CW\*(C`authorization_required_response\*(C'\fR and \f(CW\*(C`authenticate\*(C'\fR, but not the \*(L"manual\*(R" methods. .IP "authorization_required_message" 4 .IX Item "authorization_required_message" Set this to a string to override the default body content \*(L"Authorization required.\*(R", or set to undef to suppress body content being generated. .IP "password_type" 4 .IX Item "password_type" The type of password returned by the user object. Same usage as in Catalyst::Authentication::Credential::Password .IP "password_field" 4 .IX Item "password_field" The name of accessor used to retrieve the value of the password field from the user object. Same usage as in Catalyst::Authentication::Credential::Password .IP "username_field" 4 .IX Item "username_field" The field name that the user's username is mapped into when finding the user from the realm. Defaults to 'username'. .IP "use_uri_for" 4 .IX Item "use_uri_for" If this configuration key has a true value, then the domain(s) for the authorization header will be run through \f(CW$c\fR\->\fIuri_for()\fR. Use this configuration option if your application is not running at the root of your domain, and you want to ensure that authentication credentials from your application are not shared with other applications on the same server. .IP "require_ssl" 4 .IX Item "require_ssl" If this configuration key has a true value then authentication will be denied (and a 401 issued in normal circumstances) unless the request is via https. .IP "no_unprompted_authorization_required" 4 .IX Item "no_unprompted_authorization_required" Causes authentication to fail as normal modules do, without calling \&\f(CW\*(C`$c\->detach\*(C'\fR. This means that the basic auth credential can be used as part of the progressive realm. .Sp However use like this is probably not optimum it also means that users in browsers ill never get a \s-1HTTP\s0 authenticate dialogue box (unless you manually return a 401 response in your application), and even some automated user agents (for APIs) will not send the Authorization header without specific manipulation of the request headers. .IP "broken_dotnet_digest_without_query_string" 4 .IX Item "broken_dotnet_digest_without_query_string" Enables support for .NET (or other similarly broken clients), which fails to include the query string in the uri in the digest Authorization header, contrary to rfc2617. .Sp This option has no effect on clients that include the query string; they will continue to work as normal. .SH "RESTRICTIONS" .IX Header "RESTRICTIONS" When using digest authentication, this module will only work together with authentication stores whose User objects have a \f(CW\*(C`password\*(C'\fR method that returns the plain-text password. It will not work together with Catalyst::Authentication::Store::Htpasswd, or Catalyst::Authentication::Store::DBIC stores whose \&\f(CW\*(C`password\*(C'\fR methods return a hashed or salted version of the password. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1RFC 2617\s0 (or its successors), Catalyst::Plugin::Cache, Catalyst::Plugin::Authentication .SH "SUPPORT" .IX Header "SUPPORT" Bugs may be submitted through the \s-1RT\s0 bug tracker (or bug\-Catalyst\-Authentication\-Credential\-HTTP@rt.cpan.org ). .PP There is also a mailing list available for users of this distribution, at . .PP There is also an irc channel available for users of this distribution, at \&\f(CW\*(C`#catalyst\*(C'\fR on \f(CW\*(C`irc.perl.org\*(C'\fR . .SH "AUTHOR" .IX Header "AUTHOR" יובל קוג'מן (Yuval Kogman) .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" .IP "\(bu" 4 Tomas Doran .IP "\(bu" 4 Karen Etheridge .IP "\(bu" 4 Sascha Kiefer .IP "\(bu" 4 Devin Austin .IP "\(bu" 4 Ronald J Kimball .IP "\(bu" 4 Jess Robinson .IP "\(bu" 4 Ronald J Kimball .IP "\(bu" 4 Tomas Doran .IP "\(bu" 4 Ton Voon .IP "\(bu" 4 J. Shirley .IP "\(bu" 4 Brian Cassidy .IP "\(bu" 4 Jonathan Rockway .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is copyright (c) 2006 by יובל קוג'מן (Yuval Kogman). .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.