/usr/lib/python2.6/site-packages/keystoneclient/middleware
NameSizeModeActions
auth_token.py646860644editdlrm
auth_token.pyc556180644editdlrm
memcache_crypt.py61720644editdlrm
memcache_crypt.pyc73060644editdlrm
s3_token.py108580644editdlrm
s3_token.pyc87200644editdlrm
__init__.py00644editdlrm
__init__.pyc1680644editdlrm
Edit: /usr/lib/python2.6/site-packages/keystoneclient/middleware/auth_token.pyc (55618B)
d?dd@e idAddBddCe idDddEddFe idGdeddHe idIded)e"ddJe i dKde"ddLe idMddNddOe i dPde!ddQe i#dRddSgddTgZ$e i%Z%e%i&e$dUdVdWdXgZ'dYZ(dZe)fd[YZ*d\Z+d]Z,d^Z-d_Z.d`Z/daZ0dbZ1dce2fddYZ3dee2fdfYZ4dge2fdhYZ5die2fdjYZ6dke)fdlYZ7dme)fdnYZ8doe9fdpYZ:dqe)fdrYZ;dsZ<dtZ=e>dujoddvZ?ddwk@lAZAhdxd6dyd(6ZBe8e?eBZCeAiDddzeCZEd{GHeEiFndS(|s TOKEN-BASED AUTH MIDDLEWARE .. warning:: This module is DEPRECATED. The auth_token middleware has been moved to the `keystonemiddleware repository `_. This WSGI component: * Verifies that incoming client requests have valid tokens by validating tokens with the auth service. * Rejects unauthenticated requests UNLESS it is in 'delay_auth_decision' mode, which means the final decision is delegated to the downstream WSGI component (usually the OpenStack service) * Collects and forwards identity information based on a valid token such as user name, tenant, etc HEADERS ------- * Headers starting with HTTP\_ is a standard http header * Headers starting with HTTP_X is an extended http header Coming in from initial call from client or customer ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ HTTP_X_AUTH_TOKEN The client token being passed in. HTTP_X_STORAGE_TOKEN The client token being passed in (legacy Rackspace use) to support swift/cloud files Used for communication between components ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ WWW-Authenticate HTTP header returned to a user indicating which endpoint to use to retrieve a new token What we add to the request for use by the OpenStack service ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ HTTP_X_IDENTITY_STATUS 'Confirmed' or 'Invalid' The underlying service will only see a value of 'Invalid' if the Middleware is configured to run in 'delay_auth_decision' mode HTTP_X_DOMAIN_ID Identity service managed unique identifier, string. Only present if this is a domain-scoped v3 token. HTTP_X_DOMAIN_NAME Unique domain name, string. Only present if this is a domain-scoped v3 token. HTTP_X_PROJECT_ID Identity service managed unique identifier, string. Only present if this is a project-scoped v3 token, or a tenant-scoped v2 token. HTTP_X_PROJECT_NAME Project name, unique within owning domain, string. Only present if this is a project-scoped v3 token, or a tenant-scoped v2 token. HTTP_X_PROJECT_DOMAIN_ID Identity service managed unique identifier of owning domain of project, string. Only present if this is a project-scoped v3 token. If this variable is set, this indicates that the PROJECT_NAME can only be assumed to be unique within this domain. HTTP_X_PROJECT_DOMAIN_NAME Name of owning domain of project, string. Only present if this is a project-scoped v3 token. If this variable is set, this indicates that the PROJECT_NAME can only be assumed to be unique within this domain. HTTP_X_USER_ID Identity-service managed unique identifier, string HTTP_X_USER_NAME User identifier, unique within owning domain, string HTTP_X_USER_DOMAIN_ID Identity service managed unique identifier of owning domain of user, string. If this variable is set, this indicates that the USER_NAME can only be assumed to be unique within this domain. HTTP_X_USER_DOMAIN_NAME Name of owning domain of user, string. If this variable is set, this indicates that the USER_NAME can only be assumed to be unique within this domain. HTTP_X_ROLES Comma delimited list of case-sensitive role names HTTP_X_SERVICE_CATALOG json encoded keystone service catalog (optional). For compatibility reasons this catalog will always be in the V2 catalog format even if it is a v3 token. HTTP_X_TENANT_ID *Deprecated* in favor of HTTP_X_PROJECT_ID Identity service managed unique identifier, string. For v3 tokens, this will be set to the same value as HTTP_X_PROJECT_ID HTTP_X_TENANT_NAME *Deprecated* in favor of HTTP_X_PROJECT_NAME Project identifier, unique within owning domain, string. For v3 tokens, this will be set to the same value as HTTP_X_PROJECT_NAME HTTP_X_TENANT *Deprecated* in favor of HTTP_X_TENANT_ID and HTTP_X_TENANT_NAME Keystone-assigned unique identifier, string. For v3 tokens, this will be set to the same value as HTTP_X_PROJECT_ID HTTP_X_USER *Deprecated* in favor of HTTP_X_USER_ID and HTTP_X_USER_NAME User name, unique within owning domain, string HTTP_X_ROLE *Deprecated* in favor of HTTP_X_ROLES Will contain the same values as HTTP_X_ROLES. OTHER ENVIRONMENT VARIABLES --------------------------- keystone.token_info Information about the token discovered in the process of validation. This may include extended information returned by the Keystone token validation call, as well as basic information about the tenant and user. iN(tcfg(t jsonutils(t timeutils(turllib(taccess(tcms(t exceptions(tmemcache_crypt(t memorycache(tutilstauth_admin_prefixtdefaulttthelpsMPrefix to prepend at the beginning of the path. Deprecated, use identity_uri.t auth_hosts 127.0.0.1sMHost providing the admin Identity API endpoint. Deprecated, use identity_uri.t auth_portisFPort of the admin Identity API endpoint. Deprecated, use identity_uri.t auth_protocolthttpssZProtocol of the admin Identity API endpoint (http or https). Deprecated, use identity_uri.tauth_uris%Complete public Identity API endpointt identity_urisuComplete admin Identity API endpoint. This should specify the unversioned root endpoint e.g. https://localhost:35357/t auth_versions.API version of the admin Identity API endpointtdelay_auth_decisionsDo not handle authorization requests within the middleware, but delegate the authorization decision to downstream WSGI componentsthttp_connect_timeoutsARequest timeout value for communicating with Identity API server.thttp_request_max_retriesisVHow many times are we trying to reconnect when communicating with Identity API Server.t admin_tokentsecrets/This option is deprecated and may be removed in a future release. Single shared secret with the Keystone configuration used for bootstrapping a Keystone installation, or otherwise bypassing the normal authentication process. This option should not be used, use `admin_user` and `admin_password` instead.t admin_usersKeystone account usernametadmin_passwordsKeystone account passwordtadmin_tenant_nametadmins<Keystone service account tenant name to validate user tokenstcachesEnv key for the swift cachetcertfiles7Required if Keystone server requires client certificatetkeyfiletcafilesdA PEM encoded Certificate Authority to use when verifying HTTPs connections. Defaults to system CAs.tinsecuresVerify HTTPS connections.t signing_dirs3Directory used to cache files related to PKI tokenstmemcached_serverstdeprecated_nametmemcache_serverssOptionally specify a list of memcached server(s) to use for caching. If left undefined, tokens will instead be cached in-process.ttoken_cache_timei,sIn order to prevent excessive effort spent validating tokens, the middleware caches previously-seen tokens for a configurable duration (in seconds). Set to -1 to disable caching completely.trevocation_cache_timei sDetermines the frequency at which the list of revoked tokens is retrieved from the Identity service (in seconds). A high number of revocation events combined with a low cache duration may significantly reduce performance.tmemcache_security_strategys|(optional) if defined, indicate whether token data should be authenticated or authenticated and encrypted. Acceptable values are MAC or ENCRYPT. If MAC, token data is authenticated (with HMAC) in the cache. If ENCRYPT, token data is encrypted and authenticated in the cache. If the value is not one of these options or empty, auth_token will raise an exception on initialization.tmemcache_secret_keysf(optional, mandatory if memcache_security_strategy is defined) this string is used for key derivation.tinclude_service_catalogs(optional) indicate whether to set the X-Service-Catalog header. If False, middleware will not ask for service catalog on token validation and will not set the X-Service-Catalog header.tenforce_token_bindt permissivesUsed to control the use and type of token binding. Can be set to: "disabled" to not check token binding. "permissive" (default) to validate binding information if the bind type is of a form known to the server and ignore it if not. "strict" like "permissive" but if the bind type is unknown the token will be rejected. "required" any form of token binding is needed to be allowed. Finally the name of a binding method that must be present in tokens.tcheck_revocations_for_cachedsIf true, the revocation list will be checked for cached tokens. This requires that PKI tokens are configured on the Keystone server.thash_algorithmstmd5sHash algorithms to use for hashing PKI tokens. This may be a single algorithm or multiple. The algorithms are those supported by Python standard hashlib.new(). The hashes will be tried in the order given, so put the preferred one first for performance. The result of the first hash will be stored in the cache. This will typically be set to multiple values only while migrating from a less secure algorithm to a more secure one. Once all the old tokens are expired this option should be set to a single value for better performance.tgrouptkeystone_authtokensv2.0sv3.0s tokens/%st BIND_MODEcBs&eZdZdZdZdZdZRS(tdisabledR-tstricttrequiredtkerberos(t__name__t __module__tDISABLEDt PERMISSIVEtSTRICTtREQUIREDtKERBEROS(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyR3Zs cCs&titidd}||jS(sDetermines if expiration is about to occur. :param expiry: a datetime of the expected expiration :returns: boolean : true if expiration is within 30 seconds tsecondsi(Rtutcnowtdatetimet timedelta(texpirytsoon((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pytwill_expire_soonbscCs d|jS(NR((t token_info((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt _token_is_v2lscCs d|jS(Nttoken((RF((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt _token_is_v3pscCs|ptdnt|o|ddd}n,t|o|dd}n tdti|}ti|}ti}||jotdntid|dt S(NsToken authorization failedRRHtexpirest expires_attatt subsecond( tInvalidUserTokenRGRIRt parse_isotimetnormalize_timeR@R tisotimetTrue(tdatat timestampRJR@((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pytconfirm_token_not_expiredts     c Csg}x|D]}h|dd6}y|d|ds s>Unable to convert the value of %s option into correct type: %sN(tdicttoptstsixt iteritemstNoneR]t ValueErrortConfigurationError(tconft_optst opt_typestktvte((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt_conf_values_type_converts"  RNcBseZRS((R8R9(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRNst ServiceErrorcBseZRS((R8R9(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRsR|cBseZRS((R8R9(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyR|st NetworkErrorcBseZRS((R8R9(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRstMiniRespcBseZgdZRS(cCsP|ddjodg|_n |g|_t||_|iiddS(NtREQUEST_METHODtHEADR s Content-types text/plain(s Content-types text/plain(tbodyR`theadersRb(tselft error_messagetenvR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt__init__s  (R8R9R(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRst AuthProtocolcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d%d%d Zd Zed ZdZdZdZdZd%dZedZdZedZdZdZeidZdZ dZ!dZ"e#dZ$e$i%dZ$e#dZ&dZ'e&i%d Z&ed!Z(d"Z)d#Z*d$Z+RS(&s9Auth Middleware that handles authenticating client calls.c Cs2ti|idt|_|iid|iidt||_||_ |i dt ddddd d fj|_ |i d |_ |i d |_|i p|iid |i d}t|i d}|i d}|i d}ti|od|}nd|||f|_ |o#d|i |idf|_ qzn|i id|_ |idjoD|iidtii|i d|_|iid|_n|i d|_|i d|_|i d|_|i d|_|i d|_|idjotidd|_n|iid|i|id|i}||_ d |i}||_!d!|i}||_"|i d"|_#|i#o|iid#nd|_$|i d$|_%|i d%|_&|i d&|_'|i d'}t(|id(t|i d)d*|i d*d+|i d,d-|i d-d'|d.|i d.|_)d|_*d|_+t,i-d/|i d0|_.|i d1} | o t| |_/d|_0|i d2|_1|i d3|_2|i d4|_3dS(5Ntlog_names'Starting keystone auth_token middlewaresThis middleware module is deprecated as of v0.10.0 in favor of keystonemiddleware.auth_token - please update your WSGI pipeline to reference the new middleware package.Rttruettt1tontyestyRRs[Configuring admin URI using auth fragments. This is deprecated, use 'identity_uri' instead.RRRR s[%s]s %s://%s:%ss%s/%st/sConfiguring auth_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpointRR R!R"R#tprefixskeystone-signing-s3Using %s as cache directory for signing certificates%s/signing_cert.pems %s/cacert.pems%s/revoked.pemRsThe admin_token option in the auth_token middleware is deprecated and should not be used. The admin_user and admin_password options should be used instead. The admin_token option may be removed in a future release.RRRR)t cache_timeR'R/tenv_cache_nameRR$R*R?R(RRR+R.(4tloggingt getLoggerR^R8tLOGtinfotwarningRR}tappt _conf_getRRRRRtinttnetaddrt valid_ipv6tstriptrstripRzRRlturljoint cert_filetkey_filet ssl_ca_filet ssl_insecuretsigning_dirnamettempfiletmkdtemptverify_signing_dirtsigning_cert_file_nametsigning_ca_file_nametrevoked_file_nameRtadmin_token_expiryRRRt TokenCachet _token_cachet_token_revocation_listt#_token_revocation_list_fetched_timeRARBt#token_revocation_list_cache_timeoutRRRR+R.( RRR}RRRR tvalR)thttp_connect_timeout_cfg((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs   !                        cCs+||ijo |i|Sti|SdS(N(R}tCONFR2(RRW((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRas cCs|ido&|id}|iid|nd}|i}|o-x*tD]}||jo |}PqVqVWn|o|iid|n5|iidditdi|td|S(s-Determine the api version that we should use.Rs,Auth Token proceeding with requested %s apiss#Auth Token confirmed use of %s apiss<Attempted versions [%s] not in list supported by server [%s]s, s&No compatible apis supported by serverN( RRRRzt_get_supported_versionstLIST_OF_VERSIONS_TO_ATTEMPTterrortjoinR(Rtversion_to_usetversions_supported_by_servertversion((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt_choose_api_versionhs*           c Csg}|idd\}}|idjo!|iid|idn|idjo&|iid|itdnay.x'|d d D]}|i|d qWWn/tj o#|iid td nX|iiddi ||S(NtGETRis/Old keystone installation found...assuming v2.0sv2.0i,s,Unable to get version info from keystone: %ss(Unable to get version info from keystonetversionsRatids+Invalid version response format from servers.Unable to parse version response from keystones+Server reports support for api versions: %ss, ( t _json_requestt status_codeRRRbRRR]tdebugR(RRtresponseRSR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs(    cCsQ|iid|ii|yk|i||i|}|i||}||d<|i|}|i|||i ||SWnt j oi|i o8|ii d|i|hdd6|i ||S|ii d|i ||SnLtj o?}|iid|td|}|d |i|iSXd S( sHandle incoming request. Authenticate send downstream on success. Reject request if we can't authenticate. sAuthenticating user tokenskeystone.token_infos0Invalid user token - deferring reject downstreamtInvalidsX-Identity-Statuss&Invalid user token - rejecting requests Unable to obtain admin token: %ssService unavailables503 Service UnavailableN(RRRt initializet_remove_auth_headerst_get_user_token_from_headert_validate_user_tokent_build_user_headerst _add_headersRRNRRt_reject_requestRtcriticalRRR(RRtstart_responset user_tokenRFt user_headersRtresp((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt__call__s.    cCs6d}|iiddi||i||dS(skRemove headers so a user can't fake authentication. :param env: wsgi request environment sX-Identity-Statuss X-Domain-Ids X-Domain-Names X-Project-IdsX-Project-NamesX-Project-Domain-IdsX-Project-Domain-Names X-User-Ids X-User-NamesX-User-Domain-IdsX-User-Domain-NamesX-RolessX-Service-CatalogsX-Users X-Tenant-Ids X-Tenant-NamesX-TenantsX-Roles-Removing headers from request environment: %st,N(sX-Identity-Statuss X-Domain-Ids X-Domain-Names X-Project-IdsX-Project-NamesX-Project-Domain-IdsX-Project-Domain-Names X-User-Ids X-User-NamesX-User-Domain-IdsX-User-Domain-NamesX-RolessX-Service-CatalogsX-Users X-Tenant-Ids X-Tenant-NamesX-TenantsX-Role(RRRt_remove_headers(RRt auth_headers((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs* cCsn|i|d|i|d}|o|S|ip'|iid|iid|ntddS(sGet token id from request. :param env: wsgi request environment :return token id :raises InvalidUserToken if no token is provided in request s X-Auth-TokensX-Storage-Tokens.Unable to find authentication token in headerss Headers: %ssUnable to find token in headersN(t _get_headerRRRRRN(RRRH((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs  cCs?dd|ifg}td||}|d|i|iS(sRedirect client to auth server. :param env: wsgi request environment :param start_response: wsgi response callback :returns HTTPUnauthorized http response sWWW-AuthenticatesKeystone uri='%s'sAuthentication requireds401 Unauthorized(RRRR(RRRRR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRscCsX|io!t|io d|_q+n|ip|i\|_|_n|iS(sVReturn admin token, possibly fetching a new one. if self.admin_token_expiry is set from fetching an admin token, check it for expiration, and request a new token is the existing token is about to expire. :return admin token id :raise ServiceError when unable to retrieve token from keystone N(RRERzRt_request_admin_token(R((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pytget_admin_tokens  c Ksgd|i|idf}|id|i|io$|io|i|if|ds.Unable to parse expiration time from token: %sN( RRRRtAssertionErrorRRORPR]RRRR{(RtparamsRRSRHRCtdatetime_expiry((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRds2       c Csd}y>|ii|\}}|d}|o_|}|ioKxH|D]<}|i|} | o |iidtdqIqIWq n}ti |o%|i ||} t i | }nHti |o%|i||} t i | }n|i||}t|} |i|||ii||| |SWntj o9|iiddt|iidtdnatj oT|iiddt|o|ii|n|iidtdnXdS(sDAuthenticate user token :param user_token: user's token id :param retry: Ignored, as it is not longer relevant :return uncrypted body of the token if the token is valid :raise InvalidUserToken if token is rejected :no longer raises ServiceError since it no longer makes RPC is&Token is marked as having been revokedsToken authorization failedsToken validation failure.texc_infosAuthorization failed for tokenN(RzRR^R.t_is_token_id_in_revoked_listRRRNRtis_pkiztverify_pkiz_tokenRRt is_asn1_tokentverify_signed_tokentverify_uuid_tokenRUt_confirm_token_bindtstoreRRRRRt store_invalid( RRRRttoken_idt token_idstcachedRSttidt is_revokedtverifiedRJ((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRsH     cCsstiid|}di|i}t|o|i otdnhdd6|id6|i d6|id6|i d 6|i d 6|i d 6|i d 6|id 6|id6|id6|d6|id6|id6|i d6|i d6|d6}|iid|i |i||ioP|ioC|ii}t|ot|}nti||d|D]6}|i|}y ||=Wqtj oqXqWdS(s%Remove http headers from environment.N(R'R](RRtkeysRR(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs cCs|i|}|i||S(s!Get http header from environment.(R'R^(RRR&R R(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyR scCs'|tjo d}nt|dS(NsToken authorization failed(RRN(Rtmsg((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt_invalid_user_tokens  c CsN|id}|tijodSyPt|o|ddd}n*t|o|dd}n |iWntj o h}nX|titifj}|p*|odS|i i d|in|p|ti jo d}n|}|o.||jo!|i i d||inxt i|D]\}}|tijo|iddid jp|i i d |in|id |jp|i i d |in|i id qE|tijo%|i idh|d6|d6qE|i i dh|d6|d6|iqEWdS(NR,RRHtbinds%No bind information present in token.s*Named bind mode %s not in bind informationt AUTH_TYPER t negotiates.Kerberos credentials required and not present.t REMOTE_USERs0Kerberos credentials do not match those in bind.s(Kerberos bind authentication successful.sIIgnoring Unknown bind for permissive mode: %(bind_type)s: %(identifier)s.t bind_typet identifiers<Couldn`t verify unknown bind: %(bind_type)s: %(identifier)s.(RR3R:RGRIR+R]R;R<RRR=RzRxRyR>R^R_R( RRSRt bind_modeR,R-RWR0R1((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRsR          cCs|ip|i|_n|idjo`h|id6t|d6}d}|ip|d}n|id|d|\}}n<h|id6}|iddt|d|\}}|id jo|S|id jo |iid t d n|id jo|ii dd|_ n|ii d|i|o!|ii d|i|tS|iid|t dS(sAuthenticate user token with keystone. :param user_token: user's token id :param retry: flag that forces the middleware to retry user authentication when an indeterminate response is received. Optional. :returns: token object received from keystone on success :raise InvalidUserToken: if token is rejected :raise ServiceError: if unable to authenticate token sv3.0s X-Auth-TokensX-Subject-Tokens/v3/auth/tokenss ?nocatalogRRs/v2.0/tokens/%siisAuthorization failed for tokensToken authorization failedis(Keystone rejected admin token, resettings,Bad response code while validating token: %ssRetrying validations)Invalid user token. Keystone response: %sN(RRRRpR+RRRRRNRRzRRRR(RRRRRRRS((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRWsB      cCs:x3|D]+}|i|o|iidtSqWtS(s:Indicate whether the token appears in the revocation list.s&Token is marked as having been revoked(RRRRRR(RR R ((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pytis_signed_token_revokeds  cCsA|i}|idd}|ptSd|D}||jS(s=Indicate whether the token_id appears in the revocation list.trevokedcssx|]}|dVqWdS(RN((Rttx((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pys s N(ttoken_revocation_listR^RzR(RR trevocation_listtrevoked_tokenst revoked_ids((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs  csfd}y |SWnitij oZiiy |SWqtij o"}iid|iqXnXdS(sVerifies the signature of the provided data's IAW CMS syntax. If either of the certificate files might be missing, fetch them and retry. c sdy,tiiididSWn1tiij o}iid|nXdS(Ntinformsutf-8sVerify error: %s( Rt cms_verifyRRtdecodet subprocesstCalledProcessErrorRR(terr(RSRR:(sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs sCMS Verify output: %sN(RtCertificateConfigErrortfetch_signing_certt fetch_ca_certRRtoutput(RRSR:RR?((RR:RSsS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyR;s     cCsB|i|otdnti|}|i|}|S(s<Check that the token is unrevoked and has a valid signature.sToken has been revoked(R3RNRt token_to_cmsR;(Rt signed_textR t formattedR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs cCsu|i|otdny/ti|}|i|dti}|SWntj ot|nXdS(NsToken has been revokedR:(R3RNRtpkiz_uncompressR;t PKIZ_CMS_FORMt TypeError(RRER t uncompressedR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRscCstii|ioti|itiptd|inti}ti|ii |jo|i i d|nti ti|ii }|tijo)|i i dt|ttiqnti|itidS(Nsunable to access signing_dir %sssigning_dir is not owned by %ss$signing_dir mode is %s instead of %s(tosRtexistsRRtW_OKR|tgetuidtstattst_uidRRtS_IMODEtst_modetS_IRWXUtocttmakedirs(Rtuidt current_mode((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs   !cCsk|ipZtii|io+tii|i}tii|}n tii}||_n|iS(N( RRKRRLRtgetmtimeRAtutcfromtimestamptmin(Rtmtimet fetched_time((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt"token_revocation_list_fetched_times   cCs ||_dS(N(R(Rtvalue((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyR]scCs|i|i}ti|j}|oz|ipltiohdd6nh}t|id|i i }z%|~}t i |i |_WdQXqn|i|_|iS(Nsutf-8tencodingtr(R]RRR@RRxtPY3topenRt__exit__t __enter__RRtreadtfetch_revocation_listR6(RRtlist_is_currentt open_kwargst_[1]tf((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyR6s  ,&cs}t|tio|id}nfd}y|||Wn0ttfj oi|||nXdS(Nsutf-8cs\tididtii}z|~}|i|WdQXti|i |dS(Ntdirtdelete( RtNamedTemporaryFileRRRcRdtwriteRKtrenameRW(t destinationRSRiRj(R(sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt _atomic_write s (t isinstanceRxt text_typetencodetOSErrortIOErrorR(Rt file_nameR^Rq((RsS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt_atomic_write_to_signing_dirs cCs8ti||_ti|_|i|i|dS(smSave a revocation list to memory and to disk. :param value: A json-encoded revocation list N(RRRRR@R]RxR(RR^((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyR6scCsh|id6}|iddd|\}}|idjo5|o*|iidd|_|idtSn|idjot d nd |jot d n|i |d S( Ns X-Auth-TokenRs/v2.0/tokens/revokedRis4Keystone rejected admin token, resetting admin tokenRis&Unable to fetch token revocation list.tsigneds%Revocation list improperly formatted.( RRRRRRzRRfRRR;(RRRRRS((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRf"s   cCs|ip|i|_n|idjo%|djo d}nd|}n d|}|id|}|idjoti|in|i||idS(Nsv3.0tsigningt certificatess/v3/OS-SIMPLE-CERT/s/v2.0/certificates/Ri(RRRRRR@RRx(Rtcert_file_namet cert_typeRR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt_fetch_cert_file2s    cCs|i|iddS(NRz(R~R(R((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRAAscCs|i|iddS(Ntca(R~R(R((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRBDsN(,R8R9t__doc__RRRRRRRRRRRzRRRRRRR'RRRRR+RRR3RRt PKI_ASN1_FORMR;RRRtpropertyR]tsetterR6RxRfR~RARB(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRsJ ~  !  $    (# * 4 1    @ 6       t CachePoolcBs)eZdZdZeidZRS(s A lazy pool of cache references.cCs||_||_dS(N(t_environment_cachet_memcached_servers(RRR$((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRKs c css|idj o |iVdSy|i}Wn%tj oti|i}nXz |VWd|i|XdS(s3Context manager to manage a pooled cache reference.N(RRztpopt IndexErrorRt get_clientRRb(Rtc((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pytreserveOs (R8R9RRt contextlibtcontextmanagerR(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRHs RcBsneZdZdZd d d d d d dZdZdZdZdZ dZ dZ d Z RS( sEncapsulates the auth_token token cache functionality. auth_token caches tokens that it's seen so that when a token is re-used the middleware doesn't have to do a more expensive operation (like going to the identity server) to validate the token. initialize() must be called before calling the other methods. Store a valid token in the cache using store(); mark a token as invalid in the cache using store_invalid(). Check if a token is in the cache and retrieve it using get(). tinvalidcCs||_||_||_||_||_||_|idj o|ii|_n||_d|_ t |_ |i dS(N( Rt _cache_timet_hash_algorithmst_env_cache_nameRt_memcache_security_strategyRzR%t_memcache_secret_keyt _cache_poolRt _initializedt(_assert_valid_memcache_protection_config(RtlogRR/RR$R)R*((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRus         cCs=|iodSt|i|i|i|_t|_dS(N(RRR^RRRRR(RR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs  cstiptio\tfd|iD}x/|D]'}|i|}|o ||fSqFW|dfS}|i|}|g|fS(sSCheck if the token is cached already. Returns a tuple. The first element is a list of token IDs, where the first one is the preferred hash. The second element is the token data from the cache if the token was cached, otherwise ``None``. :raises InvalidUserToken: if the token is invalid c3s(x!|]}tid|VqWdS(tmodeN(Rtcms_hash_token(Rttalgo(R(sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pys s N(RRRR`Rt _cache_getRz(RRt token_hashest token_hashR R ((RsS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyR^s  cCs*|iid|i|||fdS(sPut token data into the cache. Stores the parsed expire date in cache allowing quick check of token freshness on retrieval. sStoring token in cacheN(RRt _cache_store(RR RSRJ((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRscCs'|iid|i||idS(sStore invalid token in cache.s&Marking token as unauthorized in cacheN(RRRt_INVALID_INDICATOR(RR ((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRscCsL|io>|idjotdn|iptdqHndS(NtMACtENCRYPTs1memcache_security_strategy must be ENCRYPT or MACsPmemcache_secret_key must be defined when a memcache_security_strategy is defined(RR(RR|R(R((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs   c Csx|pdS|idjoIt|}|iiii}z|~}|i|}WdQXn |i}t |t i o|i d}n|i}t |t i o|i d}nt i|||}tt i|} |iiii} z| ~ }|i| } WdQXyt i|| }Wn/tj o#d} |ii| d}nX|djodSt |t i p|id}nti|} | |ijo |iidtdn| \}}yti|}Wntj odSXti|}ti}||jo|iid|S|iidtddS(sReturn token information from cache. If token is invalid raise InvalidUserToken return token only if fresh (not expired). Nsutf-8s#Failed to decrypt/verify cache datas#Cached Token is marked unauthorizedsToken authorization failedsReturning cached tokensCached Token seems expired(RRztCACHE_KEY_TEMPLATERRRcRdR^RRrRxt string_typesRtRt derive_keyst get_cache_keytunprotect_dataRRt exceptionR<RRRRRNRROR{RPR@(RR R&RiRt serializedt secret_keytsecurity_strategyR)t cache_keyt_[2]t raw_cachedR*R RSRJR@((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs^ &   &       c Cs:ti|}t|tio|id}n|idjot|}|}n|i }t|ti o|id}n|i}t|ti o|id}nt i |||}tt i |}t i||}|iiii} z&| ~ } | i||d|iWdQXdS(slStore value into memcache. data may be _INVALID_INDICATOR or a tuple like (data, expires) sutf-8RN(RRRrRxRsRtRRzRRRRRRt protect_dataRRRcRdtsetR( RR RStserialized_dataRt data_to_storeRRR)RiR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRs$    &N( R8R9RRRzRRR^RRRRR(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyRcs   Ic s,|ii|fd}|S(s4Returns a WSGI filter app for use with paste.deploy.cs t|S(N(R(R(R}(sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt auth_filter5s(tcopyR(t global_conft local_confR((R}sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pytfilter_factory0s  cKs&|i}|i|td|S(N(RRRRz(RRR}((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyt app_factory:s  t__main__ccsA|ddgtdti|D}ti|VdS(s?A WSGI application that echoes the CGI environment to the user.s200 OKs Content-Typesapplication/jsoncss9x2|]+\}}|ido||fVqqWdS(tHTTP_X_N(t startswith(RtRR((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pys Ms N(s Content-Typesapplication/json(RvRxRyRR(tenvironRt environment((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pytecho_appJs(t simple_serverthttptADMINi@s'Serving on port 8000 (Ctrl+C to end)...(GRRRARRKRORRRt oslo_configRtoslo_serializationRt oslo_utilsRRRxt six.movesRtkeystoneclientRtkeystoneclient.commonRRtkeystoneclient.middlewareRtkeystoneclient.openstack.commonRR tStrOpttIntOptRztBoolOptRRRtListOptRwRt register_optsRRtobjectR3RERGRIRURkRpRRRNRR|RRRR`RRRRR8RtwsgirefRR}Rt make_servertservert serve_forever(((sS/tmp/pip-build-cD3xZi/python-keystoneclient/keystoneclient/middleware/auth_token.pyts                                         $   k