Package openid :: Package extensions :: Module sreg
[hide private]
[frames] | no frames]

Module sreg

source code

Simple registration request and response parsing and object representation

This module contains objects representing simple registration requests and responses that can be used with both OpenID relying parties and OpenID providers.

  1. The relying party creates a request object and adds it to the AuthRequest object before making the checkid_ request to the OpenID provider:
    auth_request.addExtension(SRegRequest(required=['email']))
    
  2. The OpenID provider extracts the simple registration request from the OpenID request using SRegRequest.fromOpenIDRequest, gets the user's approval and data, creates a SRegResponse object and adds it to the id_res response:
    sreg_req = SRegRequest.fromOpenIDRequest(checkid_request)
    # [ get the user's approval and data, informing the user that
    #   the fields in sreg_response were requested ]
    sreg_resp = SRegResponse.extractResponse(sreg_req, user_data)
    sreg_resp.toMessage(openid_response.fields)
    
  3. The relying party uses SRegResponse.fromSuccessResponse to extract the data from the OpenID response:
    sreg_resp = SRegResponse.fromSuccessResponse(success_response)
    

Since: 2.0

Classes [hide private]
  SRegNamespaceError
The simple registration namespace was not found and could not be created using the expected name (there's another extension using the name 'sreg')
  SRegRequest
An object to hold the state of a simple registration request.
  SRegResponse
Represents the data returned in a simple registration response inside of an OpenID id_res response.
Functions [hide private]
 
checkFieldName(field_name)
Check to see that the given value is a valid simple registration data field name.
source code
bool
supportsSReg(endpoint)
Does the given endpoint advertise support for simple registration?
source code
str
getSRegNS(message)
Extract the simple registration namespace URI from the given OpenID message.
source code
Variables [hide private]
  basestring = str, unicode
  data_fields = {'country': 'Country', 'dob': 'Date of Birth', '...
  ns_uri_1_0 = 'http://openid.net/sreg/1.0'
  ns_uri_1_1 = 'http://openid.net/extensions/sreg/1.1'
  ns_uri = 'http://openid.net/extensions/sreg/1.1'
  __package__ = 'openid.extensions'
  sreg_data_fields
The names of the data fields that are listed in the sreg spec, and a description of them in English
  sreg_uri
The preferred URI to use for the simple registration namespace and XRD Type value
Function Details [hide private]

checkFieldName(field_name)

source code 

Check to see that the given value is a valid simple registration data field name.

Raises:
  • ValueError - if the field name is not a valid simple registration data field name

supportsSReg(endpoint)

source code 

Does the given endpoint advertise support for simple registration?

Parameters:
  • endpoint (openid.consumer.discover.OpenIDEndpoint) - The endpoint object as returned by OpenID discovery
Returns: bool
Whether an sreg type was advertised by the endpoint

getSRegNS(message)

source code 

Extract the simple registration namespace URI from the given OpenID message. Handles OpenID 1 and 2, as well as both sreg namespace URIs found in the wild, as well as missing namespace definitions (for OpenID 1)

Parameters:
  • message (openid.message.Message) - The OpenID message from which to parse simple registration fields. This may be a request or response message.
Returns: str
the sreg namespace URI for the supplied message. The message may be modified to define a simple registration namespace.
Raises:
  • ValueError - when using OpenID 1 if the message defines the 'sreg' alias to be something other than a simple registration type.

Variables Details [hide private]

data_fields

Value:
{'country': 'Country',
 'dob': 'Date of Birth',
 'email': 'E-mail Address',
 'fullname': 'Full Name',
 'gender': 'Gender',
 'language': 'Language',
 'nickname': 'Nickname',
 'postcode': 'Postal Code',
...