Repository URL to install this package:
|
Version:
3.3.30 ▾
|
contego
/
home
/
tvault
/
.virtenv
/
lib
/
python2.7
/
site-packages
/
keystoneauth1
/
identity
/
v3
/
oidc.pyc
|
|---|
ó
µEYc @ s d d l Z d d l Z d d l m Z d d l Z d d l m Z d d l m Z d d l m Z d d l m
Z
e j e Z
d Z e j e j d e
j f d Y Z d e f d
YZ d e f d YZ d e f d YZ d
e f d YZ d S( iÿÿÿÿN( t
positional( t _utils( t access( t
exceptions( t
federationt OidcAuthorizationCodet OidcClientCredentialst OidcPasswordt OidcAccessTokent _OidcBasec B sh e Z d Z d Z d d d d d Z d Z d Z d Z d Z d Z
e j d Z
RS(
s® Base class for different OpenID Connect based flows.
The OpenID Connect specification can be found at::
``http://openid.net/specs/openid-connect-core-1_0.html``
s openid profilec K s t t | j | | | | | | _ | | _ | | _ i | _ | | _ | | _ | | _ |
d k r |
| j k r t j
n t j d t n d S( sÙ The OpenID Connect plugin expects the following.
:param auth_url: URL of the Identity Service
:type auth_url: string
:param identity_provider: Name of the Identity Provider the client
will authenticate against
:type identity_provider: string
:param protocol: Protocol name as configured in keystone
:type protocol: string
:param client_id: OAuth 2.0 Client ID
:type client_id: string
:param client_secret: OAuth 2.0 Client Secret
:type client_secret: string
:param access_token_type: OAuth 2.0 Authorization Server Introspection
token type, it is used to decide which type
of token will be used when processing token
introspection. Valid values are:
"access_token" or "id_token"
:type access_token_type: string
:param access_token_endpoint: OpenID Connect Provider Token Endpoint,
for example:
https://localhost:8020/oidc/OP/token
Note that if a discovery document is
provided this value will override
the discovered one.
:type access_token_endpoint: string
:param discovery_endpoint: OpenID Connect Discovery Document URL,
for example:
https://localhost:8020/oidc/.well-known/openid-configuration
:type access_token_endpoint: string
:param scope: OpenID Connect scope that is requested from OP,
for example: "openid profile email", defaults to
"openid profile". Note that OpenID Connect specification
states that "openid" must be always specified.
:type scope: string
sX Passing grant_type as an argument has been deprecated as it is now defined in the plugin itself. You should stop passing this argument to the plugin, as it will be ignored, since you cannot pass a free text string as a grant_type. This argument will be dropped from the plugin in July 2017 or with the next major release of keystoneauth (3.0.0)N( t superR t __init__t client_idt
client_secrett discovery_endpointt _discovery_documentt access_token_endpointt access_token_typet scopet Nonet
grant_typeR t OidcGrantTypeMissmatcht warningst warnt DeprecationWarning( t selft auth_urlt identity_providert protocolR R
R R R R R t kwargs( ( sS /home/tvault/.virtenv/lib/python2.7/site-packages/keystoneauth1/identity/v3/oidc.pyR * s 4 c C s³ | j d k r¬ | j r¬ y | j | j d t } Wn2 t j k
ri t j d i | j d 6 n Xy | j | _ Wn t
k
r n X| j s¬ t j q¬ n | j S( sà Get the contents of the OpenID Connect Discovery Document.
This method grabs the contents of the OpenID Connect Discovery Document
if a discovery_endpoint was passed to the constructor and returns it as
a dict, otherwise returns an empty dict. Note that it will fetch the
discovery document only once, so subsequent calls to this method will
return the cached result, if any.
:param session: a session object to send out HTTP requests.
:type session: keystoneauth1.session.Session
:returns: a python dictionary containing the discovery document if any,
otherwise it will return an empty dict.
:rtype: dict
t
authenticateds- Cannot fetch discovery document %(discovery)st discoveryN( R R R t gett FalseR t HttpErrort _loggert errort jsont Exceptiont InvalidOidcDiscoveryDocument( R t sessiont resp( ( sS /home/tvault/.virtenv/lib/python2.7/site-packages/keystoneauth1/identity/v3/oidc.pyt _get_discovery_documentw s
c C sS | j d k r | j S| j | } | j d } | d k rO t j n | S( s Get the "token_endpoint" for the OpenID Connect flow.
This method will return the correct access token endpoint to be used.
If the user has explicitly passed an access_token_endpoint to the
constructor that will be returned. If there is no explicit endpoint and
a discovery url is provided, it will try to get it from the discovery
document. If nothing is found, an exception will be raised.
:param session: a session object to send out HTTP requests.
:type session: keystoneauth1.session.Session
:return: the endpoint to use
:rtype: string or None if no endpoint is found
t token_endpointN( R R R* R R t OidcAccessTokenEndpointNotFound( R R( R t endpoint( ( sS /home/tvault/.virtenv/lib/python2.7/site-packages/keystoneauth1/identity/v3/oidc.pyt _get_access_token_endpoint s c C sY | j | j f } | j | } | j | d | d | d t } | j | j } | S( sé Exchange a variety of user supplied values for an access token.
:param session: a session object to send out HTTP requests.
:type session: keystoneauth1.session.Session
:param payload: a dict containing various OpenID Connect values, for
example::
{'grant_type': 'password', 'username': self.username,
'password': self.password, 'scope': self.scope}
:type payload: dict
t
requests_autht dataR ( R R
R. t postR! R% R ( R R( t payloadt client_authR t op_responset access_token( ( sS /home/tvault/.virtenv/lib/python2.7/site-packages/keystoneauth1/identity/v3/oidc.pyt _get_access_token³ s c C s3 i d | d 6} | j | j d | d t } | S( s Exchange an access token for a keystone token.
By Sending the access token in an `Authorization: Bearer` header, to
an OpenID Connect protected endpoint (Federated Token URL). The
OpenID Connect server will use the access token to look up information
about the authenticated user (this technique is called instrospection).
The output of the instrospection will be an OpenID Connect Claim, that
will be used against the mapping engine. Should the mapping engine
succeed, a Keystone token will be presented to the user.
:param session: a session object to send out HTTP requests.
:type session: keystoneauth1.session.Session
:param access_token: The OpenID Connect access token.
:type access_token: str
s Bearer t
Authorizationt headersR ( R1 t federated_token_urlR! ( R R( R5 R8 t
auth_response( ( sS /home/tvault/.virtenv/lib/python2.7/site-packages/keystoneauth1/identity/v3/oidc.pyt _get_keystone_tokenÉ s
c C s§ | j | } | j d } | rQ | j d k rQ | j | k rQ t j n | j | } | j d | j | j | | } | j | | } t
j d | S( s$ Authenticate with OpenID Connect and get back claims.
This is a multi-step process:
1.- An access token must be retrieved from the server. In order to do
so, we need to exchange an authorization grant or refresh token
with the token endpoint in order to obtain an access token. The
authorization grant varies from plugin to plugin.
2.- We then exchange the access token upon accessing the protected
Keystone endpoint (federated auth URL). This will trigger the
OpenID Connect Provider to perform a user introspection and
retrieve information (specified in the scope) about the user in the
form of an OpenID Connect Claim. These claims will be sent to
Keystone in the form of environment variables.
:param session: a session object to send out HTTP requests.
:type session: keystoneauth1.session.Session
:returns: a token data representation
:rtype: :py:class:`keystoneauth1.access.AccessInfoV3`
t grant_types_supportedR R) N( R* R R R R t OidcPluginNotSupportedt get_payloadt
setdefaultR6 R; R t create( R R( R t grant_typesR2 R5 t response( ( sS /home/tvault/.virtenv/lib/python2.7/site-packages/keystoneauth1/identity/v3/oidc.pyt get_unscoped_auth_refá s c C s
t d S( s$ Get the plugin specific payload for obtainin an access token.
OpenID Connect supports different grant types. This method should
prepare the payload that needs to be exchanged with the server in
order to get an access token for the particular grant type that the
plugin is implementing.
:param session: a session object to send out HTTP requests.
:type session: keystoneauth1.session.Session
:returns: a python dictionary containing the payload to be exchanged
:rtype: dict
N( t NotImplementedError( R R( ( ( sS /home/tvault/.virtenv/lib/python2.7/site-packages/keystoneauth1/identity/v3/oidc.pyR>