|Net::OpenID::Server-><B>newB>([ %opts ])||You can set anything in the constructor options that there are getters/setters methods for below. That includes: args, get_user, is_identity, is_trusted, setup_url, and setup_map. See below for docs.|
($type, $data) = $nos-><B>handle_pageB>([ %opts ]) Returns a $type and $data, where $type can be:
redirect ... in which case you redirect the user (via your web frameworks redirect functionality) to the URL specified in $data. setup ... in which case you should show the user a page (or redirect them to one of your pages) where they can setup trust for the given trust_root in the hashref in $data, and then redirect them to return_to at the end. Note that the parameters in the $data hashref are as you named them with setup_map. Some content type Otherwise, set the content type to $type and print the page out, the contents of which are in $data.
The optional %opts may contain:
redirect_for_setup If set to a true value, signals that you dont want to handle the setup return type from handle_page, and youd prefer it just be converted to a redirect type to your already-defined setup_url, with the arguments from setup_map already appended. $url = $nos-><B>signed_return_urlB>( %opts ) Generates a positive identity assertion URL that youd redirect a user to. Typically this would be after theyve completed your setup_url. Once trust has been setup, the handle_page method will redirect you to this signed return automatically.
The URL generated is the consumer sites return_to URL, with a signed identity included in the GET arguments. The %opts are:
identity Required. The identity URL to sign. claimed_id Optional. The claimed_id URL to sign. return_to Required. The base of the URL being generated. assoc_handle The association handle to use for the signature. If blank, dumb consumer mode is used, and the library picks the handle. trust_root Optional. If present, the return_to URL will be checked to be within (under) this trust_root. If not, the URL returned will be undef. ns Optional. additional_fields Optional. If present, must be a hashref with keys starting with \w+\.. All keys and values will be returned in the response, and signed. This is used for OpenID extensions. $url = $nos-><B>cancel_return_urlB>( %opts ) Generates a cancel notice to the return_to URL, if a user declines to share their identity. %opts are:
return_to Required. The base of the URL being generated. $nos-><B>argsB> Can be used in 1 of 3 ways:
1. Setting the way which the Server instances obtains parameters:
$nos->args( $reference )
Where $reference is either a HASH ref, CODE ref, Apache $r (for get_args only), Apache::Request $apreq, or CGI.pm $cgi. If a CODE ref, the subref must return the value given one argument (the parameter to retrieve)
2. Get a paramater:
my $foo = $nos->get_args(foo);
When given an unblessed scalar, it retrieves the value. It croaks if you havent defined a way to get at the parameters.
3. Get the getter:
my $code = $nos->get_args;
Without arguments, returns a subref that returns the value given a parameter name.
$nos-><B>get_userB>($code) $code = $nos-><B>get_userB>; $u = $code->(); Get/set the subref returning a defined value representing the logged in user, or undef if no user. The return value (lets call it $u) is not touched. Its simply given back to your other callbacks (is_identity and is_trusted). $nos-><B>get_identityB>($code) $code = $nos-><B>get_identityB>; $identity = $code->($u, $identity); For OpenID 2.0. Get/set the subref returning a identity. This is called when claimed identity is identifier_select. $nos-><B>is_identityB>($code) $code = $nos-><B>is_identityB>; $code->($u, $identity_url) Get/set the subref which is responsible for returning true if the logged in user $u (which may be undef if user isnt logged in) owns the URL tree given by $identity_url. Note that if $u is undef, your function should always return 0. The framework doesnt do that for you so you can do unnecessary work on purpose if you care about exposing information via timing attacks. $nos-><B>is_trustedB>($code) $code = $nos-><B>is_trustedB>; $code->($u, $trust_root, $is_identity) Get/set the subref which is responsible for returning true if the logged in user $u (which may be undef if user isnt logged in) trusts the URL given by $trust_root to know his/her identity. Note that if either $u is undef, or $is_identity is false (this is the result of your previous is_identity callback), you should return 0. But your callback is always run so you can avoid timing attacks, if you care. $nos-><B>server_secretB>($scalar) $nos-><B>server_secretB>($code) $code = $nos-><B>server_secretB>; ($secret) = $code->($time); The server secret is used to generate and sign lots of per-consumer secrets, and is never handed out directly.
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, all consumers that have cached their per-consumer secrets will start failing, since their secrets no longer work.
The recommended usage, however, is to supply a subref that returns a secret based on the provided $time, a unix timestamp. And if one doesnt exist for that time, create, store and return it (with appropriate locking so you never return different secrets for the same time.) Your secret can just be random characters, but its your responsibility to do the locking and storage. If you want help generating random characters, call Net::OpenID::Server::rand_chars($len).
Your secret may not exceed 255 characters.
$nos-><B>setup_urlB>($url) $url = $nos-><B>setup_urlB> Get/set the user setup URL. This is the URL the user is told to go to if theyre either not logged in, not who they said they were, or trust hasnt been setup. You use the same URL in all three cases. Your setup URL may contain existing query parameters. $nos-><B>endpoint_urlB>($url) $url = $nos-><B>endpoint_urlB> For OpenID 2.0. Get/set the op_endpoint URL. $nos-><B>setup_mapB>($hashref) $hashref = $nos-><B>setup_mapB> When this module gives a consumer site a user_setup_url from your provided setup_url, it also has to append a number of get parameters onto your setup_url, so your app based at that setup_url knows what it has to setup. Those keys are named, by default, trust_root, return_to, identity, and assoc_handle. If you dont like those parameter names, this $hashref setup_map lets you change one or more of them. The hashrefs keys should be the default values, with values being the parameter names you want. Net::OpenID::Server->rand_chars($len) Utility function to return a string of $len random characters. May be called as package method, object method, or regular function. $nos-><B>errB> Returns the last error, in form errcode: errtext; $nos-><B>errcodeB> Returns the last error code. $nos-><B>errtextB> Returns the last error text.
This module is Copyright (c) 2005 Brad Fitzpatrick. All rights reserved.
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. If you need more liberal licensing terms, please contact the maintainer.
This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.
The Net::OpenID family of modules has a mailing list powered by Google Groups. For more information, see http://groups.google.com/group/openid-perl .
OpenID website: http://openid.net/
Brad Fitzpatrick <email@example.com>
|perl v5.20.3||NET::OPENID::SERVER (3)||2011-11-10|