Module OpenID::Server
In: lib/openid/server.rb

This module contains classes specific to implemeting an OpenID server.

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 Server.decode_request and Server.encode_response methods of the OpenID::Server::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_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. Do this by examining the properties of the CheckIDRequest object, and when you‘ve come to a decision, form a response by calling CheckIDRequest.answer.

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

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 www.openidenabled.com/openid/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.

For example when request is a checkid_* request:

  response = request.answer(true)
  # this will add a signed 'openid.sreg.timezone' parameter to the response
  response.add_field('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 OpenID::Store. 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 OpenID::FilesystemStore.

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.

Classes and Modules

Class OpenID::Server::AlreadySigned
Class OpenID::Server::AssociateRequest
Class OpenID::Server::CheckAuthRequest
Class OpenID::Server::CheckIDRequest
Class OpenID::Server::Decoder
Class OpenID::Server::DiffieHellmanServerSession
Class OpenID::Server::Encoder
Class OpenID::Server::EncodingError
Class OpenID::Server::MalformedReturnURL
Class OpenID::Server::MalformedTrustRoot
Class OpenID::Server::OpenIDRequest
Class OpenID::Server::OpenIDResponse
Class OpenID::Server::PlainTextServerSession
Class OpenID::Server::ProtocolError
Class OpenID::Server::Server
Class OpenID::Server::Signatory
Class OpenID::Server::SigningEncoder
Class OpenID::Server::UntrustedReturnURL
Class OpenID::Server::WebResponse

Constants

HTTP_REDIRECT = 302
HTTP_OK = 200
HTTP_ERROR = 400
BROWSER_REQUEST_MODES = ['checkid_setup', 'checkid_immediate']
OPENID_PREFIX = 'openid.'
ENCODE_KVFORM = ['kvform'].freeze
ENCODE_URL = ['URL/redirect'].freeze

[Validate]