/Auth/OpenID/Server.php

Description

OpenID server protocol and logic.

Overview

An OpenID server must perform three tasks:

  1. Examine the incoming request to determine its nature and validity.
  2. Make a decision about how to respond to this request.
  3. Format the response according to the protocol.
The first and last of these tasks may performed by the Auth_OpenID_Server::decodeRequest() and Auth_OpenID_Server::encodeResponse methods. 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_setup' or 'checkid_immediate' request), 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 Auth_OpenID_CheckIDRequest object, and if and when you've come to a decision, form a response by calling Auth_OpenID_CheckIDRequest::answer().

Other types of requests relate to establishing associations between client and server and verifing the authenticity of previous communications. Auth_OpenID_Server contains all the logic and data necessary to respond to such requests; just pass it to Auth_OpenID_Server::handleRequest().

OpenID Extensions

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 (http://openid.net/specs/openid-simple-registration-extension-1_0.html), 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 Auth_OpenID_Request class here. But you'll likely want data sent back by your extension to be signed. Auth_OpenID_ServerResponse provides methods with which you can add data to it which can be signed with the other data in the OpenID signature.

For example:

  // 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')

Stores

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 Interface.php. 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 Auth_OpenID_FileStore. For stores based on MySQL, SQLite, or PostgreSQL, see the Auth_OpenID_SQLStore subclasses.

Upgrading

The keys by which a server looks up associations in its store have changed in version 1.2 of this library. If your store has entries created from version 1.0 code, you should empty it.

PHP versions 4 and 5

LICENSE: See the COPYING file included in this distribution.

Classes
Class Description
Auth_OpenID_ServerError An error class which gets instantiated and returned whenever an OpenID protocol error occurs. Be prepared to use this in place of an ordinary server response.
Auth_OpenID_NoReturnToError Error returned by the server code when a return_to is absent from a request.
Auth_OpenID_MalformedReturnURL An error indicating that the return_to URL is malformed.
Auth_OpenID_MalformedTrustRoot This error is returned when the trust_root value is malformed.
Auth_OpenID_Request The base class for all server request classes.
Auth_OpenID_CheckAuthRequest A request to verify the validity of a previous response.
Auth_OpenID_PlainTextServerSession A class implementing plaintext server sessions.
Auth_OpenID_DiffieHellmanSHA1ServerSession A class implementing DH-SHA1 server sessions.
Auth_OpenID_DiffieHellmanSHA256ServerSession A class implementing DH-SHA256 server sessions.
Auth_OpenID_AssociateRequest A request to associate with the server.
Auth_OpenID_CheckIDRequest A request to confirm the identity of a user.
Auth_OpenID_ServerResponse This class encapsulates the response to an OpenID server request.
Auth_OpenID_WebResponse A web-capable response object which you can use to generate a user-agent response.
Auth_OpenID_Signatory Responsible for the signature of query data and the verification of OpenID signature values.
Auth_OpenID_Encoder Encode an Auth_OpenID_ServerResponse to an Auth_OpenID_WebResponse.
Auth_OpenID_SigningEncoder An encoder which also takes care of signing fields when required.
Auth_OpenID_Decoder Decode an incoming query into an Auth_OpenID_Request.
Auth_OpenID_EncodingError An error that indicates an encoding problem occurred.
Auth_OpenID_AlreadySigned An error that indicates that a response was already signed.
Auth_OpenID_UntrustedReturnURL An error that indicates that the given return_to is not under the given trust_root.
Auth_OpenID_Server I handle requests for an OpenID server.
Includes
require_once ("Auth/OpenID/KVForm.php") (line 100)
require_once ("Auth/OpenID/ServerRequest.php") (line 102)
require_once ("Auth/OpenID/DiffieHellman.php") (line 99)
require_once ("Auth/OpenID.php") (line 95)

Required imports

require_once ("Auth/OpenID/TrustRoot.php") (line 101)
require_once ("Auth/OpenID/Message.php") (line 103)
require_once ("Auth/OpenID/Nonce.php") (line 104)
require_once ("Auth/OpenID/BigMath.php") (line 98)
require_once ("Auth/OpenID/CryptUtil.php") (line 97)
require_once ("Auth/OpenID/Association.php") (line 96)
Constants
AUTH_OPENID_HTTP_ERROR = 400 (line 108)
AUTH_OPENID_HTTP_OK = 200 (line 106)
AUTH_OPENID_HTTP_REDIRECT = 302 (line 107)

Documentation generated on Thu, 05 May 2011 19:14:25 -0400 by phpDocumentor 1.4.3