Server.php
OpenID server protocol and logic.
Overview
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 and 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 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 verifing the authenticity of previous communications. contains all the logic and data necessary to respond to such requests; just pass it to .
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 class here. But you'll likely want data sent back by your extension to be signed. 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 . For stores based on MySQL, SQLite, or PostgreSQL, see the 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.
Tags
Interfaces, Classes, Traits and Enums
- 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 {@link Auth_OpenID_ServerResponse} to an {@link 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.
Table of Contents
- Auth_OpenID_ENCODE_HTML_FORM = 'HTML form'
- Auth_OpenID_ENCODE_KVFORM = 'kfvorm'
- Auth_OpenID_ENCODE_URL = 'URL/redirect'
- AUTH_OPENID_HTTP_ERROR = 400
- AUTH_OPENID_HTTP_OK = 200
- AUTH_OPENID_HTTP_REDIRECT = 302
- Auth_OpenID_isError() : bool
Constants
Auth_OpenID_ENCODE_HTML_FORM
public
mixed
Auth_OpenID_ENCODE_HTML_FORM
= 'HTML form'
Tags
Auth_OpenID_ENCODE_KVFORM
public
mixed
Auth_OpenID_ENCODE_KVFORM
= 'kfvorm'
Tags
Auth_OpenID_ENCODE_URL
public
mixed
Auth_OpenID_ENCODE_URL
= 'URL/redirect'
Tags
AUTH_OPENID_HTTP_ERROR
public
mixed
AUTH_OPENID_HTTP_ERROR
= 400
AUTH_OPENID_HTTP_OK
public
mixed
AUTH_OPENID_HTTP_OK
= 200
AUTH_OPENID_HTTP_REDIRECT
public
mixed
AUTH_OPENID_HTTP_REDIRECT
= 302
Functions
Auth_OpenID_isError()
Auth_OpenID_isError(object|string $obj[, string $cls = 'Auth_OpenID_ServerError' ]) : bool
Parameters
- $obj : object|string
- $cls : string = 'Auth_OpenID_ServerError'