27 Jun 2006 23:43:24 UTC
- Distribution: Net-OpenID-JanRain
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2)
- Testers (0 / 273 / 0)
- KwaliteeBus factor: 0
- License: unknown
- Activity24 month
- Download (44.55KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
An OpenID server must perform three tasks:
Examine the incoming request to determine its nature and validity.
Make a decision about how to respond to this request.
Format the response according to the protocol.
The first and last of these tasks may performed by the "decodeRequest" and "encodeResponse" methods of the Server object. Who gets to do the intermediate task -- deciding how to respond to the request -- will depend on what type of request it is.
If it's a request to authenticate a user (a
checkid_immediaterequest), you need to decide if you will assert that this user may claim the identity in question. Exactly how you do that is a matter of application policy, but it generally involves making sure the user has an account with your system and is logged in, checking to see if that identity is hers to claim, and verifying with the user that she does consent to releasing that information to the party making the request.
Examine the properties of the "CheckIDRequest" object, and if and when you've come to a decision, form a response by calling
Other types of requests relate to establishing associations between client and server and verifying the authenticity of previous communications. The Server instance contains all the logic and data necessary to respond to such requests; just pass it to the "handleRequest" method.
Do you want to provide other information for your users in addition to authentication? Version 1.2 of the OpenID protocol allows consumers to add extensions to their requests. For example, with sites using the Simple Registration Extension, a user can agree to have their nickname and e-mail address sent to a site when they sign up.
Since extensions do not change the way OpenID authentication works, code to handle extension requests may be completely separate from the "OpenIDRequest" class here. But you'll likely want data sent back by your extension to be signed. "OpenIDResponse" provides methods with which you can add data to it which can be signed with the other data in the OpenID signature.
# when request is a checkid_* request response = request.answer(True) # this will a signed 'openid.sreg.timezone' parameter to the response response.addField('sreg', 'timezone', 'America/Los_Angeles')
The OpenID server needs to maintain state between requests in order to function. Its mechanism for doing this is called a store. The store interface is defined in Net::OpenID::JanRain::Stores. Additionally, several concrete store implementations are provided, so that most sites won't need to implement a custom store. For a store backed by flat files on disk, see Net::OpenID::JanRain::Stores::FileStore. For stores based on PostGreSQL, MySQL or SQLite, see the Net::OpenID::JanRain::Stores::SQLStore module.
The parent class for several types of requests. None of these classes are to be instantiated by the user, but this class will never be encountered except as a parent.
openid.modeparameter of this request.
However, it does possess an
answermethod which takes a "Net::OpenID::JanRain::Server::Signatory" object.
However, it does possess an
answermethod which takes an Net::OpenID::JanRain::Association object. It also has accessor methods
$response = $request->answer($allow, $server_url);
A boolean value: if true, sends an
id_resresponse. If false, sends a
cancelresponse if the request is not immediate, and
setup_neededif it is immediate.
This argument is required if the request is immediate, and should be the URL of the server endpoint, used to construct the setup URL.
Takes the server endpoint URL and returns a URL which would generate this request.
Returns a URL to redirect the user to send a cancel message to the consumer. Calling this method will cause croakage if the request is in immediate mode.
$is_return_to_valid_against_trust_root = checkTrustRoot($trust_root, $return_to);
This object is returned by the
answermethods of "Net::OpenID::JanRain::Server::Request" objects.
Returns 'url' if the response should be returned in a redirect URL, and 'kvform' if the response should be returned as a plaintext KV form response.
Returns a boolean value indicating whether the response should be signed.
Returns a URL for redirecting the user to send the response.
Returns a KV form string to put in the body of the HTTP response.
$response->addField($namespace, $key, $value, $signed);
Adds an OpenID field to the response, possibly in an extension namespace.
The namespace to put the field in. '' or undef will put the field in the root openid namespace.
Whether this field should be signed. Defaults to true if the response is to a
checkid_immediaterequest, and false otherwise.
$response->addFields($namespace, \%fields, $signed);
addField, but takes a hash reference containing a number key/value pairs.
An accessor method for the fields hash ref.
Returns the request this response is responding to.
This object is meant to be easily encoded into an HTTP response in your application.
The HTTP code to use on your response.
A hash reference of headers to put on your response.
The body of the response.
Objects of this class are returned by XXX when the consumer sends us an improper request. It may be encoded to a web response in the same manner that a "Net::OpenID::JanRain::Server::Response" object is encoded.
Returns a string describing the error.
returns the query that led to the error.
Do we have a return_to URL to send the error back to the server? (only relevant when the c<whichEncoding> method returns 'url')
Generates and returns a URL for redirecting the user to alert the consumer of the error.
Generates and returns a KV form string for returning in the body of the response to the consumer.
Returns a hash ref of the response fields.
Returns a string, either 'url', or 'kvform', based on how the error should be encoded for transmission.
This object signs responses and checks signatures. One is contained inside every
If you use the "encodeResponse" method of the
Net::OpenID::JanRain::Serverobject, you won't have to know how this object works. All the object state is in the OpenID store.
$is_valid = $signatory->verify($assoc_handle, $sig, $signed_pairs);
$assoc = $signatory->createAssociation($dumbp);
$assoc = $signatory->getAssociation($assoc_handle, $dumb);
This object handles requests for an OpenID server.
Requests which are not
checkidrequests may be passed to the handleRequest method, and a response will be returned.
"Net::OpenID::JanRain::Server::Response" objects may be transformed into "Net::OpenID::JanRain::Server::WebResponse" objects with the endodeResponse method, which will also sign the responses if necessary.
$server = new Net::OpenID::JanRain::Server($store);
Instantiate this object with an instance of
Call this method on a "Net::OpenID::JanRain::Server::Request" object that is not a "Net::OpenID::JanRain::Server::CheckIDRequest" and the appropriate "Net::OpenID::JanRain::Server::Response" object will be returned.
An accessor method to get the signatory object used by the server.
$response = $server->decodeRequest(\%query);
This method takes a hash ref of an OpenID query and returns an "Net::OpenID::JanRain::Server::Request" object.
$web_response = $server->encodeResponse($response);
Module Install Instructions
To install Net::OpenID::JanRain::Util, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Net::OpenID::JanRain::Util
For more information on module installation, please visit the detailed CPAN module installation guide.