Package openid :: Package server :: Module server :: Class Server
[frames] | no frames]

Class Server

source code

object --+
         |
        Server

I handle requests for an OpenID server.

Some types of requests (those which are not checkid requests) may be handed to my handleRequest method, and I will take care of it and return a response.

For your convenience, I also provide an interface to Decoder.decode and SigningEncoder.encode through my methods decodeRequest and encodeResponse.

All my state is encapsulated in an OpenIDStore, which means I'm not generally pickleable but I am easy to reconstruct.

Example:
   oserver = Server(FileOpenIDStore(data_path), "http://example.com/op")
   request = oserver.decodeRequest(query)
   if request.mode in ['checkid_immediate', 'checkid_setup']:
       if self.isAuthorized(request.identity, request.trust_root):
           response = request.answer(True)
       elif request.immediate:
           response = request.answer(False)
       else:
           self.showDecidePage(request)
           return
   else:
       response = oserver.handleRequest(request)

   webresponse = oserver.encode(response)


Nested Classes [hide private]
  signatoryClass
I sign things.
  encoderClass
I encode responses in to WebResponses, signing them when required.
  decoderClass
I decode an incoming web request in to a OpenIDRequest.

Instance Methods [hide private]
  __init__(self, store, op_endpoint=None)
A new Server.
OpenIDResponse handleRequest(self, request)
Handle a request.
OpenIDResponse openid_check_authentication(self, request)
Handle and respond to check_authentication requests.
OpenIDResponse openid_associate(self, request)
Handle and respond to associate requests.
OpenIDRequest decodeRequest(self, query)
Transform query parameters into an OpenIDRequest.
WebResponse encodeResponse(self, response)
Encode a response to a WebResponse, signing it first if appropriate.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Instance Variables [hide private]
Decoder decoder
I'm using this to decode things.
Encoder encoder
I'm using this to encode things.
openid.association.SessionNegotiator negotiator
I use this to determine which kinds of associations I can make and how.
str op_endpoint
My URL.
Signatory signatory
I'm using this for associate requests and to sign things.

Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, store, op_endpoint=None)
(Constructor)

source code 

A new Server.
Parameters:
  • store (openid.store.interface.OpenIDStore) - The back-end where my associations are stored.
  • op_endpoint (str) - My URL, the fully qualified address of this server's endpoint, i.e. http://example.com/server
Overrides: object.__init__

Change Log: op_endpoint is new in library version 2.0. It currently defaults to None for compatibility with earlier versions of the library, but you must provide it if you want to respond to any version 2 OpenID requests.

handleRequest(self, request)

source code 

Handle a request.

Give me a request, I will give you a response. Unless it's a type of request I cannot handle myself, in which case I will raise NotImplementedError. In that case, you can handle it yourself, or add a method to me for handling that request type.
Returns: OpenIDResponse
Raises:
  • NotImplementedError - When I do not have a handler defined for that type of request.

openid_check_authentication(self, request)

source code 

Handle and respond to check_authentication requests.
Returns: OpenIDResponse

openid_associate(self, request)

source code 

Handle and respond to associate requests.
Returns: OpenIDResponse

decodeRequest(self, query)

source code 

Transform query parameters into an OpenIDRequest.

If the query does not seem to be an OpenID request at all, I return None.
Parameters:
  • query (dict) - The query parameters as a dictionary with each key mapping to one value.
Returns: OpenIDRequest
Raises:
  • ProtocolError - When the query does not seem to be a valid OpenID request.

See Also: Decoder.decode

encodeResponse(self, response)

source code 

Encode a response to a WebResponse, signing it first if appropriate.
Returns: WebResponse
Raises:

See Also: SigningEncoder.encode


Instance Variable Details [hide private]

decoder


I'm using this to decode things.
Type:
Decoder

encoder


I'm using this to encode things.
Type:
Encoder

negotiator


I use this to determine which kinds of associations I can make and how.
Type:
openid.association.SessionNegotiator

op_endpoint


My URL.
Type:
str

signatory


I'm using this for associate requests and to sign things.
Type:
Signatory