Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: OpenID

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5

File/openid/Auth/OpenID/Consumer.php

Description

This module documents the main interface with the OpenID consumer

library. The only part of the library which has to be used and isn't documented in full here is the store required to create an Auth_OpenID_Consumer instance. More on the abstract store type and concrete implementations of it that are provided in the documentation for the Auth_OpenID_Consumer constructor.

OVERVIEW

The OpenID identity verification process most commonly uses the following steps, as visible to the user of this library:

  1. The user enters their OpenID into a field on the consumer's site, and hits a login button.
  2. The consumer site discovers the user's OpenID server using the YADIS protocol.
  3. The consumer site sends the browser a redirect to the identity server. This is the authentication request as described in the OpenID specification.
  4. The identity server's site sends the browser a redirect back to the consumer site. This redirect contains the server's response to the authentication request.
The most important part of the flow to note is the consumer's site must handle two separate HTTP requests in order to perform the full identity check.

LIBRARY DESIGN

This consumer library is designed with that flow in mind. The goal is to make it as easy as possible to perform the above steps securely.

At a high level, there are two important parts in the consumer library. The first important part is this module, which contains the interface to actually use this library. The second is the Auth_OpenID_Interface class, which describes the interface to use if you need to create a custom method for storing the state this library needs to maintain between requests.

In general, the second part is less important for users of the library to know about, as several implementations are provided which cover a wide variety of situations in which consumers may use the library.

This module contains a class, Auth_OpenID_Consumer, with methods corresponding to the actions necessary in each of steps 2, 3, and 4 described in the overview. Use of this library should be as easy as creating an Auth_OpenID_Consumer instance and calling the methods appropriate for the action the site wants to take.

STORES AND DUMB MODE

OpenID is a protocol that works best when the consumer site is able to store some state. This is the normal mode of operation for the protocol, and is sometimes referred to as smart mode. There is also a fallback mode, known as dumb mode, which is available when the consumer site is not able to store state. This mode should be avoided when possible, as it leaves the implementation more vulnerable to replay attacks.

The mode the library works in for normal operation is determined by the store that it is given. The store is an abstraction that handles the data that the consumer needs to manage between http requests in order to operate efficiently and securely.

Several store implementation are provided, and the interface is fully documented so that custom stores can be used as well. See the documentation for the Auth_OpenID_Consumer class for more information on the interface for stores. The implementations that are provided allow the consumer site to store the necessary data in several different ways, including several SQL databases and normal files on disk.

There is an additional concrete store provided that puts the system in dumb mode. This is not recommended, as it removes the library's ability to stop replay attacks reliably. It still uses time-based checking to make replay attacks only possible within a small window, but they remain possible within that window. This store should only be used if the consumer site has no way to retain data between requests at all.

IMMEDIATE MODE

In the flow described above, the user may need to confirm to the lidentity server that it's ok to authorize his or her identity. The server may draw pages asking for information from the user before it redirects the browser back to the consumer's site. This is generally transparent to the consumer site, so it is typically ignored as an implementation detail.

There can be times, however, where the consumer site wants to get a response immediately. When this is the case, the consumer can put the library in immediate mode. In immediate mode, there is an extra response possible from the server, which is essentially the server reporting that it doesn't have enough information to answer the question yet. In addition to saying that, the identity server provides a URL to which the user can be sent to provide the needed information and let the server finish handling the original request.

USING THIS LIBRARY

Integrating this library into an application is usually a relatively straightforward process. The process should basically follow this plan:

Add an OpenID login field somewhere on your site. When an OpenID is entered in that field and the form is submitted, it should make a request to the your site which includes that OpenID URL.

First, the application should instantiate the Auth_OpenID_Consumer class using the store of choice (Auth_OpenID_FileStore or one of the SQL-based stores). If the application has any sort of session framework that provides per-client state management, a dict-like object to access the session should be passed as the optional second parameter. (The default behavior is to use PHP's standard session machinery.)

Next, the application should call the Auth_OpenID_Consumer object's 'begin' method. This method takes the OpenID URL. The 'begin' method returns an Auth_OpenID_AuthRequest object.

Next, the application should call the 'redirectURL' method of the Auth_OpenID_AuthRequest object. The 'return_to' URL parameter is the URL that the OpenID server will send the user back to after attempting to verify his or her identity. The 'trust_root' is the URL (or URL pattern) that identifies your web site to the user when he or she is authorizing it. Send a redirect to the resulting URL to the user's browser.

That's the first half of the authentication process. The second half of the process is done after the user's ID server sends the user's browser a redirect back to your site to complete their login.

When that happens, the user will contact your site at the URL given as the 'return_to' URL to the Auth_OpenID_AuthRequest::redirectURL call made above. The request will have several query parameters added to the URL by the identity server as the information necessary to finish the request.

Lastly, instantiate an Auth_OpenID_Consumer instance as above and call its 'complete' method, passing in all the received query arguments.

There are multiple possible return types possible from that method. These indicate the whether or not the login was successful, and include any additional information appropriate for their type.

PHP versions 4 and 5

LICENSE: See the COPYING file included in this distribution.

Classes
Class Description
 class Auth_OpenID_Consumer An OpenID consumer implementation that performs discovery and does session management. See the Consumer.php file documentation for more information.
 class Auth_OpenID_DiffieHellmanConsumerSession
 class Auth_OpenID_PlainTextConsumerSession
 class Auth_OpenID_AuthRequest This class represents an authentication request from a consumer to an OpenID server.
 class Auth_OpenID_ConsumerResponse The base class for responses from the Auth_OpenID_Consumer.
 class Auth_OpenID_SuccessResponse A response with a status of Auth_OpenID_SUCCESS. Indicates that
 class Auth_OpenID_FailureResponse A response with a status of Auth_OpenID_FAILURE. Indicates that the OpenID protocol has failed. This could be locally or remotely triggered. This has three relevant attributes:
 class Auth_OpenID_CancelResponse A response with a status of Auth_OpenID_CANCEL. Indicates that the user cancelled the OpenID authentication request. This has two relevant attributes:
 class Auth_OpenID_SetupNeededResponse A response with a status of Auth_OpenID_SETUP_NEEDED. Indicates that the request was in immediate mode, and the server is unable to authenticate the user without further interaction.
Includes
 require_once ("Auth/OpenID/Discover.php") (line 173)
 require_once ("Auth/OpenID/KVForm.php") (line 172)
 require_once ("Auth/OpenID/DiffieHellman.php") (line 171)
 require_once ("Auth/OpenID.php") (line 167)

Require utility classes and functions for the consumer.

 require_once ("Services/Yadis/Manager.php") (line 174)
 require_once ("Services/Yadis/XRI.php") (line 175)
 require_once ("Auth/OpenID/Association.php") (line 169)
 require_once ("Auth/OpenID/HMACSHA1.php") (line 168)
 require_once ("Auth/OpenID/CryptUtil.php") (line 170)
Constants
Auth_OpenID_CANCEL = 'cancel' (line 186)

Status to indicate cancellation of OpenID authentication.

Auth_OpenID_DEFAULT_NONCE_CHRS = "abcdefghijklmnopqrstuvwxyz"."ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" (line 212)

This is the characters that the nonces are made from.

Auth_OpenID_FAILURE = 'failure' (line 192)

This is the status code completeAuth returns when the value it received indicated an invalid login.

Auth_OpenID_PARSE_ERROR = 'parse error' (line 207)

This is the status code beginAuth returns when the page fetched from the entered OpenID URL doesn't contain the necessary link tags to function as an identity page.

Auth_OpenID_SETUP_NEEDED = 'setup needed' (line 200)

This is the status code completeAuth returns when the Auth_OpenID_Consumer instance is in immediate mode, and the identity server sends back a URL to send the user to to complete his or her login.

Auth_OpenID_SUCCESS = 'success' (line 181)

This is the status code returned when the complete method returns successfully.


Documentation generated on Mon, 05 Mar 2007 20:54:59 +0000 by phpDocumentor 1.3.1