1 | """WSGI Middleware components - OpenID Provider package Attribute Exchange |
---|
2 | Interface plugins sub-package |
---|
3 | |
---|
4 | NERC DataGrid Project""" |
---|
5 | __author__ = "P J Kershaw" |
---|
6 | __date__ = "27/03/09" |
---|
7 | __copyright__ = "(C) 2009 Science and Technology Facilities Council" |
---|
8 | __license__ = "BSD - see LICENSE file in top-level directory" |
---|
9 | __contact__ = "Philip.Kershaw@stfc.ac.uk" |
---|
10 | __revision__ = '$Id$' |
---|
11 | from ndg.security.server.wsgi.openid.provider import IdentityMapping |
---|
12 | |
---|
13 | class AXInterfaceError(Exception): |
---|
14 | """Base class for Attribute Exchange Interface Errors""" |
---|
15 | |
---|
16 | class AXInterfaceConfigError(AXInterfaceError): |
---|
17 | """Attribute Exchange Interface configuration error""" |
---|
18 | |
---|
19 | class MissingRequiredAttrs(AXInterfaceError): |
---|
20 | """Raised by the AXInterface __call__ method if the Relying Party has |
---|
21 | requested attributes that this OpenID Provider cannot or is unable to |
---|
22 | release""" |
---|
23 | |
---|
24 | class AXInterfaceRetrieveError(AXInterfaceError): |
---|
25 | """Error retrieving attributes from use repository""" |
---|
26 | |
---|
27 | class AXInterfaceReloginRequired(AXInterfaceError): |
---|
28 | """Raise from AXInterface.__call__ if re-login is required""" |
---|
29 | |
---|
30 | class AXInterface(object): |
---|
31 | """Interface class for OpenID Provider to respond to Attribute Exchange |
---|
32 | Requests from a Relying Party""" |
---|
33 | __slots__ = () |
---|
34 | |
---|
35 | userIdentifier2IdentityURI = IdentityMapping.userIdentifier2IdentityURI |
---|
36 | identityUri2UserIdentifier = IdentityMapping.identityUri2UserIdentifier |
---|
37 | |
---|
38 | def __init__(self, **cfg): |
---|
39 | """Add custom settings from the OpenID Provider's |
---|
40 | openid.provider.axResponse.* settings contained in the host |
---|
41 | Paste ini file |
---|
42 | |
---|
43 | @type cfg: dict |
---|
44 | @param cfg: dictionary of configuration parameters read in from |
---|
45 | openid.provider.axinterface.* config settings. |
---|
46 | @raise AXInterfaceConfigError: if settings are missing or incorrect""" |
---|
47 | raise NotImplementedError() |
---|
48 | |
---|
49 | def __call__(self, ax_req, ax_resp, authnInterface, authnCtx): |
---|
50 | """Add the attributes to the ax_resp object requested in the ax_req |
---|
51 | object. If it is not possible to return them, raise |
---|
52 | MissingRequiredAttrs error |
---|
53 | |
---|
54 | @type ax_req: openid.extensions.ax.FetchRequest |
---|
55 | @param ax_req: attribute exchange request object. To find out what |
---|
56 | attributes the Relying Party has requested for example, call |
---|
57 | ax_req.getRequiredAttrs() |
---|
58 | @type ax_resp: openid.extensions.ax.FetchResponse |
---|
59 | @param ax_resp: attribute exchange response object. This method should |
---|
60 | update the settings in this object. Use addValue and setValues methods |
---|
61 | @type authnInterface: AbstractAuthNInterface |
---|
62 | @param authnInterface: custom authentication interface set |
---|
63 | at login. See |
---|
64 | ndg.security.server.openid.provider.AbstractAuthNInterface for more |
---|
65 | information |
---|
66 | @type authnCtx: dict like |
---|
67 | @param authnCtx: session containing authentication context information |
---|
68 | such as username and OpenID user identifier URI snippet |
---|
69 | """ |
---|
70 | raise NotImplementedError() |
---|