.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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 .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::OpenID::Consumer 3pm" .TH Net::OpenID::Consumer 3pm "2022-06-30" "perl v5.34.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" Net::OpenID::Consumer \- Library for consumers of OpenID identities .SH "VERSION" .IX Header "VERSION" version 1.18 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::OpenID::Consumer; \& \& my $csr = Net::OpenID::Consumer\->new( \& ua => LWPx::ParanoidAgent\->new, \& cache => Cache::File\->new( cache_root => \*(Aq/tmp/mycache\*(Aq ), \& args => $cgi, \& consumer_secret => ..., \& required_root => "http://site.example.com/", \& assoc_options => [ \& max_encrypt => 1, \& session_no_encrypt_https => 1, \& ], \& ); \& \& # Say a user enters "bradfitz.com" as his/her identity. The first \& # step is to perform discovery, i.e., fetch that page, parse it, \& # find out the actual identity provider and other useful information, \& # which gets encapsulated in a Net::OpenID::ClaimedIdentity object: \& \& my $claimed_identity = $csr\->claimed_identity("bradfitz.com"); \& unless ($claimed_identity) { \& die "not actually an openid? " . $csr\->err; \& } \& \& # We can then launch the actual authentication of this identity. \& # The first step is to redirect the user to the appropriate URL at \& # the identity provider. This URL is constructed as follows: \& # \& my $check_url = $claimed_identity\->check_url( \& return_to => "http://example.com/openid\-check.app?yourarg=val", \& trust_root => "http://example.com/", \& \& # to do a "checkid_setup mode" request, in which the user can \& # interact with the provider, e.g., so that the user can sign in \& # there if s/he has not done so already, you will need this, \& delayed_return => 1 \& \& # otherwise, this will be a "check_immediate mode" request, the \& # provider will have to immediately return some kind of answer \& # without interaction \& ); \& \& # Once you redirect the user to $check_url, the provider should \& # eventually redirect back, at which point you need some kind of \& # handler at openid\-check.app to deal with that response. \& \& # You can either use the callback\-based API (recommended)... \& # \& $csr\->handle_server_response( \& not_openid => sub { \& die "Not an OpenID message"; \& }, \& setup_needed => sub { \& if ($csr\->message\->protocol_version >= 2) { \& # (OpenID 2) retry request in checkid_setup mode (above) \& } \& else { \& # (OpenID 1) redirect user to $csr\->user_setup_url \& } \& }, \& cancelled => sub { \& # User hit cancel; restore application state prior to check_url \& }, \& verified => sub { \& my ($vident) = @_; \& my $verified_url = $vident\->url; \& print "You are $verified_url !"; \& }, \& error => sub { \& my ($errcode,$errtext) = @_; \& die("Error validating identity: $errcode: $errcode"); \& }, \& ); \& \& # ... or handle the various cases yourself \& # \& unless ($csr\->is_server_response) { \& die "Not an OpenID message"; \& } elsif ($csr\->setup_needed) { \& # (OpenID 2) retry request in checkid_setup mode \& # (OpenID 1) redirect/link/popup user to $csr\->user_setup_url \& } elsif ($csr\->user_cancel) { \& # User hit cancel; restore application state prior to check_url \& } elsif (my $vident = $csr\->verified_identity) { \& my $verified_url = $vident\->url; \& print "You are $verified_url !"; \& } else { \& die "Error validating identity: " . $csr\->err; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is the Perl \s-1API\s0 for (the consumer half of) OpenID, a distributed identity system based on proving you own a \s-1URL,\s0 which is then your identity. More information is available at: .PP .Vb 1 \& http://openid.net/ .Ve .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .IP "\fBnew\fR" 4 .IX Item "new" .Vb 1 \& my $csr = Net::OpenID::Consumer\->new( %options ); .Ve .Sp The following option names are recognized: \&\f(CW\*(C`ua\*(C'\fR, \&\f(CW\*(C`cache\*(C'\fR, \&\f(CW\*(C`args\*(C'\fR, \&\f(CW\*(C`consumer_secret\*(C'\fR, \&\f(CW\*(C`minimum_version\*(C'\fR, \&\f(CW\*(C`required_root\*(C'\fR, \&\f(CW\*(C`assoc_options\*(C'\fR, and \&\f(CW\*(C`nonce_options\*(C'\fR in the constructor. In each case the option value is treated exactly as the argument to the corresponding method described below under Configuration. .SH "METHODS" .IX Header "METHODS" .SS "State" .IX Subsection "State" .ie n .IP "$csr\->\fBmessage\fR($key)" 4 .el .IP "\f(CW$csr\fR\->\fBmessage\fR($key)" 4 .IX Item "$csr->message($key)" Returns the value for the given key/field from the OpenID protocol message contained in the request \s-1URL\s0 parameters (i.e., the value for the \s-1URL\s0 parameter \f(CW\*(C`openid.$key\*(C'\fR). This can only be used to obtain core OpenID fields not extension fields. .Sp Calling this method without a \f(CW$key\fR argument returns a Net::OpenID::IndirectMessage object representing the protocol message, at which point the various object methods are available, including .Sp .Vb 3 \& $csr\->message\->protocol_version \& $csr\->message\->has_ext \& $csr\->message\->get_ext .Ve .Sp Returns undef in either case if no \s-1URL\s0 parameters have been supplied (i.e., because \fBargs\fR() has not been initialized) or if the request is not an actual OpenID message. .ie n .IP "$csr\->\fBerr\fR" 4 .el .IP "\f(CW$csr\fR\->\fBerr\fR" 4 .IX Item "$csr->err" Returns the last error, in form \*(L"errcode: errtext\*(R", as set by the various handlers below. .ie n .IP "$csr\->\fBerrcode\fR" 4 .el .IP "\f(CW$csr\fR\->\fBerrcode\fR" 4 .IX Item "$csr->errcode" Returns the last error code. See Error Codes below. .ie n .IP "$csr\->\fBerrtext\fR" 4 .el .IP "\f(CW$csr\fR\->\fBerrtext\fR" 4 .IX Item "$csr->errtext" Returns the last error text. .ie n .IP "$csr\->\fBjson_err\fR" 4 .el .IP "\f(CW$csr\fR\->\fBjson_err\fR" 4 .IX Item "$csr->json_err" Returns the last error code/text in \s-1JSON\s0 format. .SS "Configuration" .IX Subsection "Configuration" .ie n .IP "$csr\->\fBua\fR($user_agent)" 4 .el .IP "\f(CW$csr\fR\->\fBua\fR($user_agent)" 4 .IX Item "$csr->ua($user_agent)" .PD 0 .ie n .IP "$csr\->\fBua\fR" 4 .el .IP "\f(CW$csr\fR\->\fBua\fR" 4 .IX Item "$csr->ua" .PD Getter/setter for the LWP::UserAgent (or subclass) instance which will be used when direct \s-1HTTP\s0 requests to a provider are needed. It's highly recommended that you use LWPx::ParanoidAgent, or at least read its documentation so you're aware of why you should care. .ie n .IP "$csr\->\fBcache\fR($cache)" 4 .el .IP "\f(CW$csr\fR\->\fBcache\fR($cache)" 4 .IX Item "$csr->cache($cache)" .PD 0 .ie n .IP "$csr\->\fBcache\fR" 4 .el .IP "\f(CW$csr\fR\->\fBcache\fR" 4 .IX Item "$csr->cache" .PD Getter/setter for the cache instance which is used for storing fetched \&\s-1HTML\s0 or \s-1XRDS\s0 pages, keys for associations with identity providers, and received response_nonce values from positive provider assertions. .Sp The \f(CW$cache\fR object can be anything that has a \->get($key) and \&\->set($key,$value[,$expire]) methods. See URI::Fetch for more information. This cache object is passed to URI::Fetch directly. .Sp Setting a cache instance is not absolutely required, But without it, provider associations will not be possible and the same pages may be fetched multiple times during discovery. \&\fBIt will also not be possible to check for repetition of the response_nonce, which may then leave you open to replay attacks.\fR .ie n .IP "$csr\->\fBconsumer_secret\fR($scalar)" 4 .el .IP "\f(CW$csr\fR\->\fBconsumer_secret\fR($scalar)" 4 .IX Item "$csr->consumer_secret($scalar)" .PD 0 .ie n .IP "$csr\->\fBconsumer_secret\fR($code)" 4 .el .IP "\f(CW$csr\fR\->\fBconsumer_secret\fR($code)" 4 .IX Item "$csr->consumer_secret($code)" .PD .Vb 1 \& $code = $csr\->B; ($secret) = $code\->($time); .Ve .Sp The consumer secret is used to generate self-signed nonces for the return_to \s-1URL,\s0 to prevent spoofing. .Sp In the simplest (and least secure) form, you configure a static secret value with a scalar. If you use this method and change the scalar value, any outstanding requests from the last 30 seconds or so will fail. .Sp You may also supply a subref that takes one argument, \fI\f(CI$time\fI\fR, a unix timestamp and returns a secret. .Sp Your secret may not exceed 255 characters. .Sp For the best protection against replays and login cross-site request forgery, consumer_secret should additionally depend on something known to be specific to the client browser instance and not visible to an attacker. If \f(CW\*(C`SSH_SESSION_ID\*(C'\fR is available, you should use that. Otherwise you'll need to set a (Secure) cookie on the (\s-1HTTPS\s0) page where the signin form appears in order to establish a pre-login session, then make sure to change this cookie upon successful login. .ie n .IP "$csr\->\fBminimum_version\fR(2)" 4 .el .IP "\f(CW$csr\fR\->\fBminimum_version\fR(2)" 4 .IX Item "$csr->minimum_version(2)" .PD 0 .ie n .IP "$csr\->\fBminimum_version\fR" 4 .el .IP "\f(CW$csr\fR\->\fBminimum_version\fR" 4 .IX Item "$csr->minimum_version" .PD Get or set the minimum OpenID protocol version supported. Currently the only useful value you can set here is 2, which will cause 1.1 identifiers to fail discovery with the error \f(CW\*(C`protocol_version_incorrect\*(C'\fR and responses from version 1 providers to not be recognized. .Sp In most cases you'll want to allow both 1.1 and 2.0 identifiers, which is the default. If you want, you can set this property to 1 to make this behavior explicit. .ie n .IP "$csr\->\fBargs\fR($ref)" 4 .el .IP "\f(CW$csr\fR\->\fBargs\fR($ref)" 4 .IX Item "$csr->args($ref)" .PD 0 .ie n .IP "$csr\->\fBargs\fR($param)" 4 .el .IP "\f(CW$csr\fR\->\fBargs\fR($param)" 4 .IX Item "$csr->args($param)" .ie n .IP "$csr\->\fBargs\fR" 4 .el .IP "\f(CW$csr\fR\->\fBargs\fR" 4 .IX Item "$csr->args" .PD Can be used in 1 of 3 ways: .RS 4 .IP "1." 4 Set the object from which \s-1URL\s0 parameter names and values are to be retrieved: .Sp .Vb 1 \& $csr\->args( $reference ) .Ve .Sp where \f(CW$reference\fR is either an unblessed \f(CW\*(C`HASH\*(C'\fR ref, a \f(CW\*(C`CODE\*(C'\fR ref, or some kind of \*(L"request object\*(R" — the latter being either a \&\s-1CGI\s0, Apache, Apache::Request, Apache2::Request, or Plack::Request object. .Sp If you pass in a \f(CW\*(C`CODE\*(C'\fR ref, it must, .RS 4 .IP "\(bu" 4 given a single parameter name argument, return the corresponding parameter value, \fIand\fR, .IP "\(bu" 4 given no arguments at all, return the full list of parameter names from the request. .RE .RS 4 .Sp If you pass in an Apache (mod_perl 1.x interface) object and this is a \s-1POST\s0 request, you must \fInot\fR have already called \&\f(CW\*(C`$r\->content\*(C'\fR as this routine will be making said call itself in order to extract the request parameters. .RE .IP "2." 4 Get a parameter value: .Sp .Vb 1 \& my $foo = $csr\->args("foo"); .Ve .Sp When given an unblessed scalar, it retrieves the value. It croaks if you haven't defined a way to get at the parameters. .Sp Most callers should instead use the \f(CW\*(C`message\*(C'\fR method above, which abstracts away the need to understand OpenID's message serialization. .IP "3." 4 Get the parameter getter: .Sp .Vb 1 \& my $code = $csr\->args; .Ve .Sp this being a subref that takes a parameter name and returns the corresponding value. .Sp Most callers should instead use the \f(CW\*(C`message\*(C'\fR method above with no arguments, which returns an object from which extension attributes can be obtained by their documented namespace \s-1URI.\s0 .RE .RS 4 .RE .ie n .IP "$csr\->\fBrequired_root\fR($url_prefix)" 4 .el .IP "\f(CW$csr\fR\->\fBrequired_root\fR($url_prefix)" 4 .IX Item "$csr->required_root($url_prefix)" .PD 0 .ie n .IP "$csr\->\fBrequired_root\fR" 4 .el .IP "\f(CW$csr\fR\->\fBrequired_root\fR" 4 .IX Item "$csr->required_root" .PD Gets or sets the string prefix that, if nonempty, all return_to URLs must start with. Messages with return_to \s-1URLS\s0 that don't match will be considered invalid (spoofed from another site). .ie n .IP "$csr\->\fBassoc_options\fR(...)" 4 .el .IP "\f(CW$csr\fR\->\fBassoc_options\fR(...)" 4 .IX Item "$csr->assoc_options(...)" .PD 0 .ie n .IP "$csr\->\fBassoc_options\fR" 4 .el .IP "\f(CW$csr\fR\->\fBassoc_options\fR" 4 .IX Item "$csr->assoc_options" .PD Get or sets the hash of parameters that determine how associations with identity providers will be made. Available options include: .RS 4 .ie n .IP """assoc_type""" 4 .el .IP "\f(CWassoc_type\fR" 4 .IX Item "assoc_type" Association type, (default '\s-1HMAC\-SHA1\s0') .ie n .IP """session_type""" 4 .el .IP "\f(CWsession_type\fR" 4 .IX Item "session_type" Association session type, (default '\s-1DH\-SHA1\s0') .ie n .IP """max_encrypt""" 4 .el .IP "\f(CWmax_encrypt\fR" 4 .IX Item "max_encrypt" (boolean) Use best encryption available for protocol version for both session type and association type. This overrides \f(CW\*(C`session_type\*(C'\fR and \f(CW\*(C`assoc_type\*(C'\fR .ie n .IP """session_no_encrypt_https""" 4 .el .IP "\f(CWsession_no_encrypt_https\fR" 4 .IX Item "session_no_encrypt_https" (boolean) Use an unencrypted session type if the \s-1ID\s0 provider \s-1URL\s0 scheme is \f(CW\*(C`https:\*(C'\fR. This overrides \f(CW\*(C`max_encrypt\*(C'\fR if both are set. .ie n .IP """allow_eavesdropping""" 4 .el .IP "\f(CWallow_eavesdropping\fR" 4 .IX Item "allow_eavesdropping" (boolean) Because it is generally a bad idea, we abort associations where an unencrypted session over a non-SSL connection is called for. However the OpenID 1.1 specification technically allows this, so if that is what you really want, set this flag true. Ignored under protocol version 2. .RE .RS 4 .RE .ie n .IP "$csr\->\fBnonce_options\fR(...)" 4 .el .IP "\f(CW$csr\fR\->\fBnonce_options\fR(...)" 4 .IX Item "$csr->nonce_options(...)" .PD 0 .ie n .IP "$csr\->\fBnonce_options\fR" 4 .el .IP "\f(CW$csr\fR\->\fBnonce_options\fR" 4 .IX Item "$csr->nonce_options" .PD Gets or sets the hash of options for how response_nonce should be checked. .Sp In OpenID 2.0, response_nonce is sent by the identity provider as part of a positive identity assertion in order to help prevent replay attacks. In the check_authentication phase, the provider is also required to not authenticate the same response_nonce twice. .Sp The relying party is strongly encouraged but not required to reject multiple occurrences of a nonce (which can matter if associations are in use and there is no check_authentication phase). Relying party may also choose to reject a nonce on the basis of the timestamp being out of an acceptable range. .Sp Available options include: .RS 4 .ie n .IP """nocheck""" 4 .el .IP "\f(CWnocheck\fR" 4 .IX Item "nocheck" (boolean) Skip response_nonce checking entirely. This overrides all other nonce_options. .Sp \&\f(CW\*(C`nocheck\*(C'\fR is implied and is the only possibility if \f(CW$csr\fR\->\fBcache\fR is unset. .ie n .IP """lifetime""" 4 .el .IP "\f(CWlifetime\fR" 4 .IX Item "lifetime" (integer) Cache entries for nonces will expire after this many seconds. .Sp Defaults to the value of \f(CW\*(C`window\*(C'\fR, below. .Sp If \f(CW\*(C`lifetime\*(C'\fR is zero or negative, expiration times will not be set at all; entries will expire as per the default behavior for your cache (or you will need to purge them via some separate process). .Sp If your cache implementation ignores the third argument on \&\f(CW$entry\fR\->\fBset\fR() calls (see Cache::Entry), then this option has no effect beyond serving as a default for \f(CW\*(C`window\*(C'\fR. .ie n .IP """ignoretime""" 4 .el .IP "\f(CWignoretime\fR" 4 .IX Item "ignoretime" (boolean) Do not do any checking of timestamps, i.e., only test whether nonce is in the cache. This overrides all other nonce options except for \f(CW\*(C`lifetime\*(C'\fR and \f(CW\*(C`nocheck\*(C'\fR .ie n .IP """skew""" 4 .el .IP "\f(CWskew\fR" 4 .IX Item "skew" (integer) Number of seconds that a provider clock can be ahead of ours before we deem it to be misconfigured. .Sp Default skew is 300 (5 minutes) or \f(CW\*(C`window/2\*(C'\fR, if \f(CW\*(C`window\*(C'\fR is specified and \f(CW\*(C`window/2\*(C'\fR is smaller. .Sp (\f(CW\*(C`skew\*(C'\fR is treated as 0 if set negative, but don't do that). .Sp Misconfiguration of the provider clock means its timestamps are not reliable, which then means there is no way to know whether or not the nonce could have been sent before the start of the cache window, which nullifies any obligation to detect all multiply sent nonces. Conversely, if proper configuration can be assumed, then the timestamp value minus \f(CW\*(C`skew\*(C'\fR will be the earliest possible time that we could have received a previous instance of this response_nonce, and if the cache is reliable about holding entries from that time forward, then (and only then) can one be certain that an uncached nonce instance is indeed the first. .ie n .IP """start""" 4 .el .IP "\f(CWstart\fR" 4 .IX Item "start" (integer) Reject nonces where \fItimestamp\fR minus \f(CW\*(C`skew\*(C'\fR is earlier than \f(CW\*(C`start\*(C'\fR (absolute seconds; default is zero a.k.a. midnight 1/1/1970 \s-1UTC\s0) .Sp If you know the start time of your \s-1HTTP\s0 server (or your cache server, if that is separate — or the maximum of the start times if you have multiple cache servers), you should use this option to declare that. .ie n .IP """window""" 4 .el .IP "\f(CWwindow\fR" 4 .IX Item "window" (integer) Reject nonces where \fItimestamp\fR minus \f(CW\*(C`skew\*(C'\fR is more than \f(CW\*(C`window\*(C'\fR seconds ago. Zero or negative values of \f(CW\*(C`window\*(C'\fR are treated as infinite (i.e., allow everything). .Sp If \f(CW\*(C`lifetime\*(C'\fR is specified, \f(CW\*(C`window\*(C'\fR defaults to that. If \f(CW\*(C`lifetime\*(C'\fR is not specified, \f(CW\*(C`window\*(C'\fR defaults to 1800 (30 minutes), adjusted upwards if \f(CW\*(C`skew\*(C'\fR is specified and larger than the default skew. .Sp On general principles, \f(CW\*(C`window\*(C'\fR should be a maximal expected propagation delay plus twice the \f(CW\*(C`skew\*(C'\fR. .Sp Values between 0 and \f(CW\*(C`skew\*(C'\fR (causing all nonces to be rejected) and values greater than \f(CW\*(C`lifetime\*(C'\fR (cache may fail to keep all nonces that are still within the window) are \fInot\fR recommended. .ie n .IP """timecop""" 4 .el .IP "\f(CWtimecop\fR" 4 .IX Item "timecop" (boolean) Reject nonces from The Future (i.e., timestamped more than \&\f(CW\*(C`skew\*(C'\fR seconds from now). .Sp Note that rejecting future nonces is not required. Nor does it protect from anything since an attacker can retry the message once it has expired from the cache but is still within the time interval where we would not yet \fIexpect\fR that it could expire — this being the essential problem with future nonces. It may, however, be useful to have warnings about misconfigured provider clocks — and hence about this insecurity — at the cost of impairing interoperability (since this rejects messages that are otherwise allowed by the protocol), hence this option. .RE .RS 4 .Sp In most cases it will be enough to either set \f(CW\*(C`nocheck\*(C'\fR to dispense with response_nonce checking entirely because some other (better) method of preventing replay attacks (see \fBconsumer_secret\fR) has been implemented, or use \f(CW\*(C`lifetime\*(C'\fR to declare/set the lifetime of cache entries for nonces whether because the default lifetime is unsatisfactory or because the cache implementation is incapable of setting individual expiration times. All other options should default reasonably in these cases. .Sp In order for the nonce check to be as reliable/secure as possible (i.e., that it block all instances of duplicate nonces from properly configured providers as defined by \f(CW\*(C`skew\*(C'\fR, which is the best we can do), \f(CW\*(C`start\*(C'\fR must be no earlier than the cache start time and the cache must be guaranteed to hold nonce entries for at least \f(CW\*(C`window\*(C'\fR seconds (though, to be sure, if you can tolerate being vulnerable for the first \f(CW\*(C`window\*(C'\fR seconds of a server run, then you do not need to set \f(CW\*(C`start\*(C'\fR). .RE .SS "Performing Discovery" .IX Subsection "Performing Discovery" .ie n .IP "$csr\->\fBclaimed_identity\fR($url)" 4 .el .IP "\f(CW$csr\fR\->\fBclaimed_identity\fR($url)" 4 .IX Item "$csr->claimed_identity($url)" Given a user-entered \f(CW$url\fR (which could be missing http://, or have extra whitespace, etc), converts it to canonical form, performs partial discovery to confirm that at least one provider endpoint exists, and returns a Net::OpenID::ClaimedIdentity object, or, on failure of any of the above, returns undef and sets last error ($csr\->\fBerr\fR). .Sp Note that the identity returned is \fInot\fR verified yet. It's only who the user claims they are, but they could be lying. .Sp If this method returns undef, an error code will be set. See Error Codes below. .SS "Handling Provider Responses" .IX Subsection "Handling Provider Responses" The following routines are for handling a redirected provider response and assume that, among other things, \f(CW$csr\fR\->\fBargs\fR has been properly populated with the \s-1URL\s0 parameters. .ie n .IP "$csr\->\fBhandle_server_response\fR( %callbacks );" 4 .el .IP "\f(CW$csr\fR\->\fBhandle_server_response\fR( \f(CW%callbacks\fR );" 4 .IX Item "$csr->handle_server_response( %callbacks );" When a request comes in that contains a response from an OpenID provider, figure out what it means and dispatch to an appropriate callback to handle the request. This is the callback-based alternative to explicitly calling the methods below in the correct sequence, and is recommended unless you need to do something strange. .Sp Anything you return from the selected callback function will be returned by this method verbatim. This is useful if the caller needs to return something different in each case. .Sp The available callbacks are: .RS 4 .ie n .IP """not_openid""" 4 .el .IP "\f(CWnot_openid\fR" 4 .IX Item "not_openid" the request isn't an OpenID response after all. .ie n .IP """setup_needed""" 4 .el .IP "\f(CWsetup_needed\fR" 4 .IX Item "setup_needed" a checkid_immediate mode request was rejected, indicating that the provider requires user interaction. .ie n .IP """cancelled""" 4 .el .IP "\f(CWcancelled\fR" 4 .IX Item "cancelled" the user cancelled the authentication request from the provider's \s-1UI.\s0 .ie n .IP """verified ($verified_identity)""" 4 .el .IP "\f(CWverified ($verified_identity)\fR" 4 .IX Item "verified ($verified_identity)" the user's identity has been successfully verified. A Net::OpenID::VerifiedIdentity object is passed in. .ie n .IP """error ($errcode, $errmsg)""" 4 .el .IP "\f(CWerror ($errcode, $errmsg)\fR" 4 .IX Item "error ($errcode, $errmsg)" an error has occurred. An error code and message are provided. See Error Codes below for the meanings of the codes. .RE .RS 4 .Sp For the sake of legacy code we also allow .ie n .IP """setup_required ($setup_url)""" 4 .el .IP "\f(CWsetup_required ($setup_url)\fR" 4 .IX Item "setup_required ($setup_url)" \&\fB[\s-1DEPRECATED\s0]\fR a checkid_immediate mode request was rejected \&\fIand\fR \f(CW$setup_url\fR was provided. .Sp Clients using this callback should be updated to use \fBsetup_needed\fR at the earliest opportunity. Here \f(CW$setup_url\fR is the same as returned by \&\f(CW$csr\fR\->\fBuser_setup_url\fR. .RE .RS 4 .RE .ie n .IP "$csr\->\fBis_server_response\fR" 4 .el .IP "\f(CW$csr\fR\->\fBis_server_response\fR" 4 .IX Item "$csr->is_server_response" Returns true if a set of \s-1URL\s0 parameters has been supplied (via \f(CW$csr\fR\->\fBargs\fR) and constitutes an actual OpenID protocol message. .ie n .IP "$csr\->\fBsetup_needed\fR" 4 .el .IP "\f(CW$csr\fR\->\fBsetup_needed\fR" 4 .IX Item "$csr->setup_needed" Returns true if a checkid_immediate request failed because the provider requires user interaction. The correct action to take at this point depends on the OpenID protocol version .Sp (Version 1) Redirect to or otherwise make available a link to \&\f(CW$csr\fR\->\f(CW\*(C`user_setup_url\*(C'\fR. .Sp (Version 2) Retry the request in checkid_setup mode; the provider will then issue redirects as needed. .RS 4 .Sp .RS 4 \&\fBN.B.\fR: While some providers have been known to supply the \f(CW\*(C`user_setup_url\*(C'\fR parameter in Version 2 \f(CW\*(C`setup_needed\*(C'\fR responses, you \fIcannot\fR rely on this, and, moreover, since the OpenID 2.0 specification has nothing to say about the meaning of such a parameter, you cannot rely on it meaning anything in particular even if it is supplied. .RE .RE .RS 4 .RE .ie n .IP "$csr\->\fBuser_setup_url\fR( [ %opts ] )" 4 .el .IP "\f(CW$csr\fR\->\fBuser_setup_url\fR( [ \f(CW%opts\fR ] )" 4 .IX Item "$csr->user_setup_url( [ %opts ] )" (Version 1 only) Returns the \s-1URL\s0 the user must return to in order to login, setup trust, or do whatever the identity provider needs them to do in order to make the identity assertion which they previously initiated by entering their claimed identity \s-1URL.\s0 .RS 4 .Sp .RS 4 \&\fBN.B.\fR: Checking whether \f(CW\*(C`user_setup_url\*(C'\fR is set in order to determine whether a checkid_immediate request failed is \s-1DEPRECATED\s0 and will fail under OpenID 2.0. Use \f(CW\*(C`setup_needed()\*(C'\fR instead. .RE .RE .RS 4 .Sp The base \s-1URL\s0 that this function returns can be modified by using the following options in \f(CW%opts:\fR .ie n .IP """post_grant""" 4 .el .IP "\f(CWpost_grant\fR" 4 .IX Item "post_grant" What you're asking the identity provider to do with the user after they setup trust. Can be either \f(CW\*(C`return\*(C'\fR or \f(CW\*(C`close\*(C'\fR to return the user back to the return_to \s-1URL,\s0 or close the browser window with JavaScript. If you don't specify, the behavior is undefined (probably the user gets a dead-end page with a link back to the return_to \s-1URL\s0). In any case, the identity provider can do whatever it wants, so don't depend on this. .RE .RS 4 .RE .ie n .IP "$csr\->\fBuser_cancel\fR" 4 .el .IP "\f(CW$csr\fR\->\fBuser_cancel\fR" 4 .IX Item "$csr->user_cancel" Returns true if the user declined to share their identity, false otherwise. (This function is literally one line: returns true if \&\*(L"openid.mode\*(R" eq \*(L"cancel\*(R") .Sp It's then your job to restore your app to where it was prior to redirecting them off to the user_setup_url, using the other query parameters that you'd sent along in your return_to \s-1URL.\s0 .ie n .IP "$csr\->\fBverified_identity\fR( [ %opts ] )" 4 .el .IP "\f(CW$csr\fR\->\fBverified_identity\fR( [ \f(CW%opts\fR ] )" 4 .IX Item "$csr->verified_identity( [ %opts ] )" Returns a Net::OpenID::VerifiedIdentity object, or returns undef and sets last error ($csr\->\fBerr\fR). Verification includes double-checking the reported identity \s-1URL\s0 declares the identity provider, verifying the signature, etc. .Sp The options in \f(CW%opts\fR may contain: .RS 4 .ie n .IP """required_root""" 4 .el .IP "\f(CWrequired_root\fR" 4 .IX Item "required_root" Sets the required_root just for this request. Values returns to its previous value afterwards. .RE .RS 4 .Sp If this method returns undef, an error code will be set. See Error Codes below. .RE .SH "ERROR CODES" .IX Header "ERROR CODES" This is the complete list of error codes that can be set. Errors marked with (C) are set by \fBclaimed_identity\fR. Other errors occur during handling of provider responses and can be set by \fBargs\fR (A), \fBverified_identity\fR (V), and \fBuser_setup_url\fR (S), all of which can show up in the \f(CW\*(C`error\*(C'\fR callback for \fBhandle_server_response\fR. .RS 4 .ie n .IP """provider_error""" 4 .el .IP "\f(CWprovider_error\fR" 4 .IX Item "provider_error" (A) The protocol message is a (2.0) error mode (i.e., \f(CW\*(C`openid.mode = \*(Aqerror\*(Aq\*(C'\fR) message, typically used for provider-specific error responses. Use \f(CW$csr\fR\->\fBmessage\fR to get at the \f(CW\*(C`contact\*(C'\fR and \f(CW\*(C`reference\*(C'\fR fields. .ie n .IP """empty_url""" 4 .el .IP "\f(CWempty_url\fR" 4 .IX Item "empty_url" (C) Tried to do discovery on an empty or all-whitespace string. .ie n .IP """bogus_url""" 4 .el .IP "\f(CWbogus_url\fR" 4 .IX Item "bogus_url" (C) Tried to do discovery on a non\-http:/https: \s-1URL.\s0 .ie n .IP """protocol_version_incorrect""" 4 .el .IP "\f(CWprotocol_version_incorrect\fR" 4 .IX Item "protocol_version_incorrect" (C) None of the \s-1ID\s0 providers found support even the minimum protocol version ($csr\->\fBminimum_version\fR) .ie n .IP """no_identity_server""" 4 .el .IP "\f(CWno_identity_server\fR" 4 .IX Item "no_identity_server" (\s-1CV\s0) Tried to do discovery on a \s-1URL\s0 that does not seem to have any providers at all. .ie n .IP """bad_mode""" 4 .el .IP "\f(CWbad_mode\fR" 4 .IX Item "bad_mode" (\s-1SV\s0) The \f(CW\*(C`openid.mode\*(C'\fR was expected to be \f(CW\*(C`id_res\*(C'\fR (positive assertion or, in version 1, checkid_immediate failed). .ie n .IP """no_identity""" 4 .el .IP "\f(CWno_identity\fR" 4 .IX Item "no_identity" (V) The \f(CW\*(C`openid.identity\*(C'\fR parameter is missing. .ie n .IP """no_sig""" 4 .el .IP "\f(CWno_sig\fR" 4 .IX Item "no_sig" (V) The \f(CW\*(C`openid.sig\*(C'\fR parameter is missing. .ie n .IP """no_return_to""" 4 .el .IP "\f(CWno_return_to\fR" 4 .IX Item "no_return_to" (V) The \f(CW\*(C`openid.return_to\*(C'\fR parameter is missing .ie n .IP """bogus_return_to""" 4 .el .IP "\f(CWbogus_return_to\fR" 4 .IX Item "bogus_return_to" (V) The \f(CW\*(C`return_to\*(C'\fR \s-1URL\s0 does not match \f(CW$csr\fR\->\fBrequired_root\fR .ie n .IP """nonce_missing""" 4 .el .IP "\f(CWnonce_missing\fR" 4 .IX Item "nonce_missing" (V) The \f(CW\*(C`openid.response_nonce\*(C'\fR parameter is missing. .ie n .IP """nonce_reused""" 4 .el .IP "\f(CWnonce_reused\fR" 4 .IX Item "nonce_reused" (V) A previous assertion from this provider used this response_nonce already. Someone may be attempting a replay attack. .ie n .IP """nonce_format""" 4 .el .IP "\f(CWnonce_format\fR" 4 .IX Item "nonce_format" (V) Either the response_nonce timestamp was not in the correct format (e.g., tried to have fractional seconds or not \s-1UTC\s0) or one of the components was out of range (e.g., month = 13). .ie n .IP """nonce_future""" 4 .el .IP "\f(CWnonce_future\fR" 4 .IX Item "nonce_future" (V) \f(CW\*(C`timecop\*(C'\fR was set and we got a response_nonce that was more than \f(CW\*(C`skew\*(C'\fR seconds into the future. .ie n .IP """nonce_stale""" 4 .el .IP "\f(CWnonce_stale\fR" 4 .IX Item "nonce_stale" (V) We got a response_nonce that was either prior to the start time or more than window seconds ago. .ie n .IP """time_expired""" 4 .el .IP "\f(CWtime_expired\fR" 4 .IX Item "time_expired" (V) The return_to signature time (\f(CW\*(C`oic.time\*(C'\fR) is from too long ago. .ie n .IP """time_in_future""" 4 .el .IP "\f(CWtime_in_future\fR" 4 .IX Item "time_in_future" (V) The return_to signature time (\f(CW\*(C`oic.time\*(C'\fR) is too far into the future. .ie n .IP """time_bad_sig""" 4 .el .IP "\f(CWtime_bad_sig\fR" 4 .IX Item "time_bad_sig" (V) The \s-1HMAC\s0 of the return_to signature (\f(CW\*(C`oic.time\*(C'\fR) is not what it should be. .ie n .IP """server_not_allowed""" 4 .el .IP "\f(CWserver_not_allowed\fR" 4 .IX Item "server_not_allowed" (V) None of the provider endpoints found for the given \s-1ID\s0 match the server specified by the \f(CW\*(C`openid.op_endpoint\*(C'\fR parameter (OpenID 2 only). .ie n .IP """unexpected_url_redirect""" 4 .el .IP "\f(CWunexpected_url_redirect\fR" 4 .IX Item "unexpected_url_redirect" (V) Discovery for the given \s-1ID\s0 ended up at the wrong place .ie n .IP """bogus_delegation""" 4 .el .IP "\f(CWbogus_delegation\fR" 4 .IX Item "bogus_delegation" (V) Asserted identity (\f(CW\*(C`openid.identity\*(C'\fR) does not match claimed_id or local_id/delegate. .ie n .IP """unsigned_field""" 4 .el .IP "\f(CWunsigned_field\fR" 4 .IX Item "unsigned_field" (V) In OpenID 2.0, \f(CW\*(C`openid.op_endpoint\*(C'\fR, \f(CW\*(C`openid.return_to\*(C'\fR, \f(CW\*(C`openid.response_nonce\*(C'\fR, and \f(CW\*(C`openid.assoc_handle\*(C'\fR must always be signed, while \f(CW\*(C`openid.claimed_id\*(C'\fR and \f(CW\*(C`openid.identity\*(C'\fR must be signed if present. .ie n .IP """expired_association""" 4 .el .IP "\f(CWexpired_association\fR" 4 .IX Item "expired_association" (V) \f(CW\*(C`openid.assoc_handle\*(C'\fR is for an association that has expired. .ie n .IP """signature_mismatch""" 4 .el .IP "\f(CWsignature_mismatch\fR" 4 .IX Item "signature_mismatch" (V) An attempt to confirm the positive assertion using the association given by \f(CW\*(C`openid.assoc_handle\*(C'\fR failed; the signature is not what it should be. .ie n .IP """naive_verify_failed_network""" 4 .el .IP "\f(CWnaive_verify_failed_network\fR" 4 .IX Item "naive_verify_failed_network" (V) An attempt to confirm the positive assertion via direct contact (check_authentication) with the provider failed with no response or a bad status code (!= 200). .ie n .IP """naive_verify_failed_return""" 4 .el .IP "\f(CWnaive_verify_failed_return\fR" 4 .IX Item "naive_verify_failed_return" (V) An attempt to confirm a positive assertion via direct contact (check_authentication) received an explicitly negative response (\f(CW\*(C`openid.is_valid = FALSE\*(C'\fR). .RE .RS 4 .RE .SH "PROTOCOL VARIANCES" .IX Header "PROTOCOL VARIANCES" XRI-based identities are not supported. .PP Meanwhile, here are answers to the security profile questions from section 15.6 of the OpenID 2.0 specification that are relevant to the Consumer/Relying\-Party: .IP "1." 4 \&\fIAre wildcards allowed in realms?\fR \&\fBYes.\fR .IP "2." 4 N/A. .IP "3." 4 \&\fITypes of claimed identifiers accepted.\fR \&\fB\s-1HTTP\s0 or \s-1HTTPS\s0\fR .IP "4." 4 \&\fIAre self-issued certificates allowed for authentication?\fR \&\fBDepends entirely on the user agent (\f(CB\*(C`ua\*(C'\fB) supplied. LWP::UserAgent, as of version 6.0, can be configured to only accept connections to sites with certificates deriving from a set of trusted roots.\fR .IP "5." 4 \&\fIMust the \s-1XRDS\s0 file be signed?\fR \fBNo.\fR .IP "6." 4 \&\fIMust the \s-1XRDS\s0 file be retrieved over secure channel?\fR \fBNo.\fR .IP "7." 4 \&\fIWhat types of session types can be used when creating associations?\fR \fBAny of \f(CB\*(C`no\-encryption\*(C'\fB,\f(CB\*(C`DH\-SHA1\*(C'\fB,\f(CB\*(C`DH\-SHA256\*(C'\fB\fR .IP "8." 4 N/A. .IP "9." 4 N/A. .IP "10." 4 \&\fIMust the association request take place over a secure channel?\fR \fBIf the session type is \f(CB\*(C`no\-encryption\*(C'\fB, then Yes for version 2.0 providers and likewise for version 1.1 providers if \f(CB\*(C`allow_eavesdropping\*(C'\fB is not set, otherwise No.\fR .SH "COPYRIGHT" .IX Header "COPYRIGHT" This module is Copyright (c) 2005 Brad Fitzpatrick. All rights reserved. .PP You may distribute under the terms of either the \s-1GNU\s0 General Public License or the Artistic License, as specified in the Perl \s-1README\s0 file. If you need more liberal licensing terms, please contact the maintainer. .SH "WARRANTY" .IX Header "WARRANTY" This is free software. \s-1IT COMES WITHOUT WARRANTY OF ANY KIND.\s0 .SH "MAILING LIST" .IX Header "MAILING LIST" The Net::OpenID family of modules has a mailing list powered by Google Groups. For more information, see . .SH "SEE ALSO" .IX Header "SEE ALSO" OpenID website: .PP Net::OpenID::ClaimedIdentity \*(-- part of this module .PP Net::OpenID::VerifiedIdentity \*(-- part of this module .PP Net::OpenID::Server \*(-- another module, for implementing an OpenID identity provider/server .SH "AUTHORS" .IX Header "AUTHORS" Brad Fitzpatrick .PP Tatsuhiko Miyagawa .PP Martin Atkins .PP Robert Norris .PP Roger Crew