Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
python3-tvault-contego / usr / lib / python3.6 / site-packages / contego / __pycache__ / context.cpython-36.opt-1.pyc
Size: Mime:
3

ÒƜeI.ã@s
dZddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZddlZdd
lmZddlmZddlmZejeƒZeƒZeƒZGd
d„dejƒZej Gdd„de
j!ƒƒZ!dd„Z"d dd„Z#dd„Z$dd„Z%dd„Z&dd„Z'dd„Z(dS)!zGRequestContext: context for requests that persist through all of dmapi.éN)Úcontextmanager)Úservice_catalog)Úplugin)Úcontext)Úenginefacade)Úlog)Ú	timeutils)Ú	exception)Ú_)Úutilscs2eZdZdZ‡fdd„Zdd„Zd	dd„Z‡ZS)
Ú_ContextAuthPluginzñA keystoneauth auth plugin that uses the values from the Context.

    Ideally we would use the plugin provided by auth_token middleware however
    this plugin isn't serialized yet so we construct one from the serialized
    auth data.
    cs$tt|ƒjƒ||_tj|ƒ|_dS)N)ÚsuperrÚ__init__Ú
auth_tokenÚksa_service_catalogZServiceCatalogV2r)ÚselfrZsc)Ú	__class__©ú/usr/lib/python3.6/context.pyr)sz_ContextAuthPlugin.__init__cOs|jS)N)r)rÚargsÚkwargsrrrÚ	get_token/sz_ContextAuthPlugin.get_tokenNcKs|jj||||dS)N)Úservice_typeÚservice_nameÚ	interfaceÚregion_name)rZurl_for)rZsessionrrrrrrrrÚget_endpoint2sz_ContextAuthPlugin.get_endpoint)NNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rrrÚ
__classcell__rr)rrr!s
rc
s†eZdZdZd‡fdd„	Zdd„Zd	d
„Zdd„Zd
d„Ze	eeeƒZ
‡fdd„Ze‡fdd„ƒZ
ddd„Zddd„Zdd„Z‡ZS)ÚRequestContextzpSecurity context and request information.

    Represents the user taking a given action within the system.
    NÚnoFcs¤|r||d<|r||d<|jddƒtt|ƒjfd|i|—Ž||_||_|sVtjƒ}t|t	j
ƒrltj|ƒ}||_|rˆdd„|Dƒ|_
ng|_
|	|_||_|
|_dS)aÉ:param read_deleted: 'no' indicates deleted records are hidden,
                'yes' indicates deleted records are visible,
                'only' indicates that *only* deleted records are visible.

           :param overwrite: Set to False to ensure that the greenthread local
                copy of the index is not overwritten.

           :param user_auth_plugin: The auth plugin for the current request's
                authentication data.
        ÚuserÚ
project_idZtenantNÚis_adminc
Ssg|]}|jdƒdkr|‘qS)	ÚtypeÚimageú
block-storageÚvolumev2Úvolumev3úkey-managerÚ	placementÚnetwork)r(r)r*r+r,r-r.)Úget)Ú.0Úsrrrú
<listcomp>dsz+RequestContext.__init__.<locals>.<listcomp>)Úpopr
r"rÚread_deletedÚremote_addressrZutcnowÚ
isinstanceÚsixZstring_typesZ
parse_strtimeÚ	timestamprÚinstance_lock_checkedÚquota_classÚuser_auth_plugin)rÚuser_idr%r&r4r5r8r:rr9r;r)rrrr@s(
zRequestContext.__init__cCs|jr|jSt|j|jƒSdS)N)r;rrr)rrrrÚget_auth_pluginyszRequestContext.get_auth_plugincCs|jS)N)Ú
_read_deleted)rrrrÚ_get_read_deletedsz RequestContext._get_read_deletedcCs"|dkrttdƒ|ƒ‚||_dS)Nr#ÚyesÚonlyz=read_deleted can only be one of 'no', 'yes' or 'only', not %r)r#r@rA)Ú
ValueErrorr
r>)rr4rrrÚ_set_read_deleted‚sz RequestContext._set_read_deletedcCs|`dS)N)r>)rrrrÚ_del_read_deletedˆsz RequestContext._del_read_deletedcsºtt|ƒjƒ}|jt|ddƒt|ddƒt|ddƒt|ddƒt|ddƒt|dƒrZtj|jƒndt|ddƒt|d	dƒt|d
dƒt|ddƒt|ddƒt|d
dƒdœƒ|jdt|ddƒiƒ|S)Nr<r%r&r4r#r5r8Ú
request_idr:Ú	user_namerÚproject_namer9F)r<r%r&r4r5r8rEr:rFrrGr9Zis_admin_projectT)	r
r"Úto_dictÚupdateÚgetattrÚhasattrrZstrtimer8)rÚvalues)rrrrHŽs&









zRequestContext.to_dictcsVtt|ƒj||jdƒ|jdƒ|jddƒ|jdƒ|jdƒ|jdƒ|jdƒ|jd	d
ƒd	S)Nr<r%r4r#r5r8r:rr9F)r<r%r4r5r8r:rr9)r
r"Ú	from_dictr/)ÚclsrL)rrrrM¬s

zRequestContext.from_dictcCsFtj|ƒ}tj|jƒ|_d|_d|jkr4|jjdƒ|dk	rB||_|S)z5Return a version of this context with admin flag set.TZadminN)ÚcopyÚdeepcopyZrolesr&Úappendr4)rr4rrrrÚelevated½s

zRequestContext.elevatedTcCsF|dkr|j|jdœ}ytj|||ƒStjk
r@|r<‚dSXdS)aRVerifies that the given action is valid on the target in this context.

        :param action: string representing the action to be checked.
        :param target: dictionary representing the object of the action
            for object creation this should be a dictionary representing the
            location of the object e.g. ``{'project_id': context.project_id}``.
            If None, then this default target will be considered:
            {'project_id': self.project_id, 'user_id': self.user_id}
        :param fatal: if False, will return False when an exception.Forbidden
           occurs.

        :raises dmapi.exception.Forbidden: if verification fails and fatal is
            True.

        :return: returns a non-False value (not necessarily "True") if
            authorized and False if not authorized and fatal is False.
        N)r%r<F)r%r<ZpolicyZ	authorizer	Ú	Forbidden)rÚactionÚtargetZfatalrrrÚcanÍs
zRequestContext.cancCsd|jƒS)Nz<Context %s>)rH)rrrrÚ__str__ñszRequestContext.__str__)
NNNr#NNNNFN)N)NT)rrrr rr=r?rCrDÚpropertyr4rHÚclassmethodrMrRrVrWr!rr)rrr":s 6

$r"cCstdddddS)z·A helper method to get a blank context.

    Note that overwrite is False here so this context will not update the
    greenthread-local stored context that is used when logging.
    NF)r<r%r&Ú	overwrite)r"rrrrÚget_contextõsr[r#cCstddd|ddS)NTF)r<r%r&r4rZ)r")r4rrrÚget_admin_contexts
r\cCs*|sdS|jrdS|js"|jr&dSdS)z2Indicates if the request context is a normal user.FT)r&r<r%)rrrrÚis_user_contextsr]cCs|jrt|ƒrtjƒ‚dS)zRRaise exception.Forbidden() if context is not a user or an
    admin context.
    N)r&r]r	rS)ZctxtrrrÚrequire_contextsr^cCs.t|ƒr*|jstjƒ‚n|j|kr*tjƒ‚dS)z=Ensures a request has permission to access the given project.N)r]r%r	rS)rr%rrrÚauthorize_project_context"s


r_cCs.t|ƒr*|jstjƒ‚n|j|kr*tjƒ‚dS)z:Ensures a request has permission to access the given user.N)r]r<r	rS)rr<rrrÚauthorize_user_context+s


r`cCs.t|ƒr*|jstjƒ‚n|j|kr*tjƒ‚dS)zAEnsures a request has permission to access the given quota class.N)r]r:r	rS)rÚ
class_namerrrÚauthorize_quota_class_context4s


rb)r#))r rOÚ
contextlibrZkeystoneauth1.accessrrZ
keystoneauth1rZoslo_contextrZoslo_db.sqlalchemyrZoslo_logrZloggingZ
oslo_utilsrr7Zcontegor	Zcontego.i18nr
rZ	getLoggerrZLOGÚobjectZdid_not_respond_sentinelZraised_exception_sentinelZBaseAuthPluginrZtransaction_context_providerr"r[r\r]r^r_r`rbrrrrÚ<module>s4

;