/usr/lib/python2.6/site-packages/keystoneauth1/extras/_saml2/v3
NameSizeModeActions
adfs.py183450644editdlrm
adfs.pyc162950644editdlrm
base.py33380644editdlrm
base.pyc38300644editdlrm
saml2.py142080644editdlrm
saml2.pyc128150644editdlrm
__init__.py7490644editdlrm
__init__.pyc4180644editdlrm
Edit: /usr/lib/python2.6/site-packages/keystoneauth1/extras/_saml2/v3/adfs.pyc (16295B)
Ņō 7 Wc @s…ddkZddkZddklZddklZddklZddklZddk l Z de i fd„ƒYZ dS( iĸĸĸĸN(tetree(turllib(taccess(t exceptions(tbasetPasswordcBs·eZdZdZhdd6Zhdd6Zhdd6dd6d d 6Zhdd6d d 6Zd Zd„Z d„Z dd„Z d„Z d„Z d„Zd„Zd„Zd„ZRS(s1Authentication plugin for Microsoft ADFS2.0 IdPs.ixs#application/soap+xml; charset=utf-8s Content-Types!application/x-www-form-urlencodeds'http://www.w3.org/2003/05/soap-envelopetss$http://www.w3.org/2005/08/addressingtasRhttp://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsdtus0http://docs.oasis-open.org/ws-sx/ws-trust/200512ttsZ/s:Envelope/s:Body/t:RequestSecurityTokenResponseCollection/t:RequestSecurityTokenResponsec KsDtt|ƒid|d|d|d|d|d|ƒ||_dS(sôConstructor for ``ADFSPassword``. :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. This parameter will be used to build a dynamic URL used to obtain unscoped OpenStack token. :type identity_provider: string :param identity_provider_url: An Identity Provider URL, where the SAML2 authentication request will be sent. :type identity_provider_url: string :param service_provider_endpoint: Endpoint where an assertion is being sent, for instance: ``https://host.domain/Shibboleth.sso/ADFS`` :type service_provider_endpoint: string :param username: User's login :type username: string :param password: User's password :type password: string tauth_urltidentity_providertidentity_provider_urltusernametpasswordtprotocolN(tsuperRt__init__tservice_provider_endpoint( tselfR R R RR RRtkwargs((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyR/s  cCs7yt|iƒSWntj onXt|iiƒS(sŲCheck if cookie jar is not empty. keystoneauth1.session.Session object doesn't have a cookies attribute. We should then try fetching cookies from the underlying requests.Session object. If that fails too, there is something wrong and let Python raise the AttributeError. :param session :returns: True if cookie jar is nonempty, False otherwise :raises AttributeError: in case cookies are not find anywhere (tbooltcookiestAttributeErrortsession(RR((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt_cookiesSs s%Y-%m-%dT%H:%M:%S.%fZcCsVtiiƒ}|tid|iƒ}g}||fD]}||i|ƒq9~S(sðCalculate created and expires datetime objects. The method is going to be used for building ADFS Request Security Token message. Time interval between ``created`` and ``expires`` dates is now static and equals to 120 seconds. ADFS security tokens should not be live too long, as currently ``keystoneauth1`` doesn't have mechanisms for reusing such tokens (every time ADFS authn method is called, keystoneauth1 will login with the ADFS instance). :param fmt: Datetime format for specifying string format of a date. It should not be changed if the method is going to be used for building the ADFS security token request. :type fmt: string tseconds(tdatetimetutcnowt timedeltatDEFAULT_ADFS_TOKEN_EXPIRATIONtstrftime(Rtfmtt date_createdt date_expirest_[1]t_time((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt _token_datesgs  cCsŲhdd6}hdd6}hdd6}hdd6}tid d |iƒ}ti|d ƒ}ti|d ƒ}|id dƒd|_ti|dƒ}dtiƒi|_ti|dƒ} ti| dƒ} d| _ti|dƒ} | id dƒti|dd |ƒ} | id dƒti| dƒ} | iddƒti| dƒ}ti| dƒ}|i ƒ\|_|_ti| dƒ}|iddtiƒiƒti|dƒ}ti|d d!d"ƒ}ti|d#ƒ}ti|d$d |ƒ}ti|d%d |ƒ}ti|d&d |ƒ}ti|dƒ}ti|d'ƒ}d(|_ti|d)ƒ}d*|_ti|d+ƒ}d,|_|i |_|i |_|i | _|i |_||_d-S(.s‰Build the ADFS Request Security Token SOAP message. Some values like username or password are inserted in the request. sQhttp://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsdtos0http://docs.oasis-open.org/ws-sx/ws-trust/200512ttrusts,http://schemas.xmlsoap.org/ws/2004/09/policytwsps$http://www.w3.org/2005/08/addressingtwsas1{http://www.w3.org/2003/05/soap-envelope}Envelopetnsmaps/{http://www.w3.org/2003/05/soap-envelope}Headers,{http://www.w3.org/2005/08/addressing}Actions7{http://www.w3.org/2003/05/soap-envelope}mustUnderstandt1s:http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issues/{http://www.w3.org/2005/08/addressing}MessageIDs urn:uuid:s-{http://www.w3.org/2005/08/addressing}ReplyTos-{http://www.w3.org/2005/08/addressing}Addresss.http://www.w3.org/2005/08/addressing/anonymouss({http://www.w3.org/2005/08/addressing}Tos[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Securitys]{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}TimestampsV{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Idt_0s[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Createds[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Expiress`{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameTokensU{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}us uuid-%s-1s[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Usernames[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}PasswordtTypes_http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordTexts-{http://www.w3.org/2003/05/soap-envelope}BodysF{http://docs.oasis-open.org/ws-sx/ws-trust/200512}RequestSecurityTokens7{http://schemas.xmlsoap.org/ws/2004/09/policy}AppliesTos7{http://www.w3.org/2005/08/addressing}EndpointReferences9{http://docs.oasis-open.org/ws-sx/ws-trust/200512}KeyTypes7http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearers={http://docs.oasis-open.org/ws-sx/ws-trust/200512}RequestTypes6http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issues;{http://docs.oasis-open.org/ws-sx/ws-trust/200512}TokenTypes%urn:oasis:names:tc:SAML:1.0:assertionN(RtElementt NAMESPACESt SubElementtsetttexttuuidtuuid4thexR%R RR Rtprepared_request(RtWSS_SECURITY_NAMESPACEtTRUST_NAMESPACEt WSP_NAMESPACEt WSA_NAMESPACEtroottheadertactiont messageIDtreplyIDtaddressttotsecurityt timestamptcreatedtexpirest usernametokenR Rtbodytrequest_security_tokent applies_totendpoint_referencet wsa_addresstkeytypet request_typet token_type((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt_prepare_adfs_request|sŪ                                        c s§‡fd†}ˆiˆiƒ}y.|idˆidˆid|dtƒ}Wn3tij o$}||ƒ}ti|ƒ‚nXd}ˆi |i |ƒˆ_ dS(siSend ADFS Security token to the ADFS server. Store the result in the instance attribute and raise an exception in case the response is not valid XML data. If a user cannot authenticate due to providing bad credentials, the ADFS2.0 server will return a HTTP 500 response and a XML Fault message. If ``exceptions.InternalServerError`` is caught, the method tries to parse the XML response. If parsing is unsuccessful, an ``exceptions.AuthorizationFailure`` is raised with a reason from the XML fault. Otherwise an original ``exceptions.InternalServerError`` is re-raised. :param session : a session object to send out HTTP requests. :type session: keystoneauth1.session.Session :raises keystoneauth1.exceptions.AuthorizationFailure: when HTTP response from the ADFS server is not a valid XML ADFS security token. :raises keystoneauth1.exceptions.InternalServerError: If response status code is HTTP 500 and the response XML cannot be recognized. csvd}|ii}y;ˆi|ƒi|dˆiƒ}ˆi|ƒ}|iSWn"tti fj o |‚nXdS(Ns3/s:Envelope/s:Body/s:Fault/s:Code/s:Subcode/s:Valuet namespaces( tresponsetcontentt str_to_xmltxpathR/t_firstR2t IndexErrorRtAuthorizationFailure(teRTRRtobj(R(sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt _get_failures  turltheaderstdatat authenticatedsFError parsing XML returned from the ADFS Identity Provider, reason: %sN( t xml_to_strR6tpostR t HEADER_SOAPtFalseRtInternalServerErrorRWRSRRt adfs_token(RRRZRHRQRXtreasontmsg((RsJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt_get_adfs_security_tokens  cCsq|ii|id|iƒ}|i|ƒ}|i|ƒ}|iddƒ}tii |ƒ}d||_ dS(s)Prepare ADFS Security Token to be sent to the Service Provider. The method works as follows: * Extract SAML2 assertion from the ADFS Security Token. * Replace namespaces * urlencode assertion * concatenate static string with the encoded assertion RPs0http://docs.oasis-open.org/ws-sx/ws-trust/200512s+http://schemas.xmlsoap.org/ws/2005/02/trustswa=wsignin1.0&wresult=N( RdRTtADFS_ASSERTION_XPATHtADFS_TOKEN_NAMESPACESRUR_treplaceRtparsetquotetencoded_assertion(Rt assertionRm((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt_prepare_sp_request9s  c Cs5|id|id|id|idtdtƒdS(s Send prepared assertion to a service provider. As the assertion doesn't contain a protected resource, the value from the ``location`` header is not valid and we should not let the Session object get redirected there. The aim of this call is to get a cookie in the response which is required for entering a protected endpoint. :param session : a session object to send out HTTP requests. :type session: keystoneauth1.session.Session :raises: Corresponding HTTP error exception R[R]R\tredirectR^N(R`RRmt HEADER_X_FORMRb(RR((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt#_send_assertion_to_service_providerRs cCsH|i|ƒtjotidƒ‚n|i|idtƒ|_dS(sAccess protected endpoint and fetch unscoped token. After federated authentication workflow a protected endpoint should be accessible with the session object. The access is granted basing on the cookies stored within the session object. If, for some reason no cookies are present (quantity test) it means something went wrong and user will not be able to fetch an unscoped token. In that case an ``exceptions.AuthorizationFailure` exception is raised and no HTTP call is even made. :param session : a session object to send out HTTP requests. :type session: keystoneauth1.session.Session :raises keystoneauth1.exceptions.AuthorizationFailure: in case session object has empty cookie jar. swSession object doesn't contain a cookie, therefore you are not allowed to enter the Identity Provider's protected area.R^N(RRbRRWtgettfederated_token_urltauthenticated_response(RR((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt_access_service_providerds  cGsN|iƒ|i|ƒ|iƒ|i|ƒ|i|ƒtid|iƒS(sjRetrieve unscoped token after authentcation with ADFS server. This is a multistep process: * Prepare ADFS Request Securty Token - build an etree.XML object filling certain attributes with proper user credentials, created/expires dates (ticket is be valid for 120 seconds as currently we don't handle reusing ADFS issued security tokens). * Send ADFS Security token to the ADFS server. Step handled by * Receive and parse security token, extract actual SAML assertion and prepare a request addressed for the Service Provider endpoint. This also includes changing namespaces in the XML document. Step handled by ``ADFSPassword._prepare_sp_request()`` method. * Send prepared assertion to the Service Provider endpoint. Usually the server will respond with HTTP 301 code which should be ignored as the 'location' header doesn't contain protected area. The goal of this operation is fetching the session cookie which later allows for accessing protected URL endpoints. Step handed by ``ADFSPassword._send_assertion_to_service_provider()`` method. * Once the session cookie is issued, the protected endpoint can be accessed and an unscoped token can be retrieved. Step handled by ``ADFSPassword._access_service_provider()`` method. :param session: a session object to send out HTTP requests. :type session: keystoneauth1.session.Session :returns: AccessInfo :rtype: :py:class:`keystoneauth1.access.AccessInfo` tresp(RORgRoRrRvRtcreateRu(RRR((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pytget_unscoped_auth_ref}s $     (t__name__t __module__t__doc__RRaRqR/RiRhRRR%RORgRoRrRvRy(((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyRs*     $   ‡ 6   ( RR3tlxmlRt six.movesRt keystoneauth1RRtkeystoneauth1.extras._saml2.v3RtBaseSAMLPluginR(((sJ/tmp/pip-build-wCUybK/keystoneauth1/keystoneauth1/extras/_saml2/v3/adfs.pyt s