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    
Size: Mime:
ó
Á}ac@s`dZddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZddlZdd
lmZddlmZddlmZejeƒZeƒZeƒZd
ejfd„ƒYZej de
j!fd„ƒYƒZ!d„Z"dd„Z#d„Z$d„Z%d„Z&d„Z'd„Z(dS(sGRequestContext: context for requests that persist through all of dmapi.iÿÿÿÿN(tcontextmanager(tservice_catalog(tplugin(tcontext(tenginefacade(tlog(t	timeutils(t	exception(t_(tutilst_ContextAuthPlugincBs5eZdZd„Zd„Zddddd„ZRS(sñ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.
    cCs2tt|ƒjƒ||_tj|ƒ|_dS(N(tsuperR
t__init__t
auth_tokentksa_service_catalogtServiceCatalogV2R(tselfR
tsc((s3/usr/lib/python2.7/dist-packages/contego/context.pyR)s	cOs|jS(N(R
(Rtargstkwargs((s3/usr/lib/python2.7/dist-packages/contego/context.pyt	get_token/sc	Ks%|jjd|d|d|d|ƒS(Ntservice_typetservice_namet	interfacetregion_name(Rturl_for(RtsessionRRRRR((s3/usr/lib/python2.7/dist-packages/contego/context.pytget_endpoint2sN(t__name__t
__module__t__doc__RRtNoneR(((s3/usr/lib/python2.7/dist-packages/contego/context.pyR
!s
		tRequestContextcBs§eZdZddddddddedd„
Zd„Zd„Zd„Zd„Z	e
eee	ƒZd„Ze
d„ƒZdd	„Zded
„Zd„ZRS(
spSecurity context and request information.

    Represents the user taking a given action within the system.
    tnoc

Ksø|r||d<n|r&||d<ntt|ƒjd||||_||_|sitjƒ}nt|tj	ƒrtj
|ƒ}n||_|rÐg|D]!}|jdƒd
kr£|^q£|_
n	g|_
|	|_||_|
|_dS(sÉ: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.
        tuserttenanttis_adminttypetimages
block-storagetvolumev2tvolumev3skey-managert	placementtnetworkN(R&s
block-storageR'R(skey-managerR)R*(RR Rtread_deletedtremote_addressRtutcnowt
isinstancetsixtstring_typest
parse_strtimet	timestamptgetRtinstance_lock_checkedtquota_classtuser_auth_plugin(
Rtuser_idt
project_idR$R+R,R2R5RR4R6Rts((s3/usr/lib/python2.7/dist-packages/contego/context.pyR@s,

			
				cCs'|jr|jSt|j|jƒSdS(N(R6R
R
R(R((s3/usr/lib/python2.7/dist-packages/contego/context.pytget_auth_pluginxs	cCs|jS(N(t
_read_deleted(R((s3/usr/lib/python2.7/dist-packages/contego/context.pyt_get_read_deleted~scCs2|dkr%ttdƒ|ƒ‚n||_dS(NR!tyestonlys=read_deleted can only be one of 'no', 'yes' or 'only', not %r(snosyessonly(t
ValueErrorRR;(RR+((s3/usr/lib/python2.7/dist-packages/contego/context.pyt_set_read_deleteds
cCs
|`dS(N(R;(R((s3/usr/lib/python2.7/dist-packages/contego/context.pyt_del_read_deleted‡scCs?tt|ƒjƒ}|jit|ddƒd6t|ddƒd6t|ddƒd6t|ddƒd6t|ddƒd6t|dƒržtj|j	ƒndd6t|ddƒd6t|d	dƒd	6t|d
dƒd
6t|ddƒd6t|ddƒd6t|d
t
ƒd
6ƒ|jit|dtƒd6ƒ|S(NR7R8R$R+R!R,R2t
request_idR5t	user_nameRtproject_nameR4tis_admin_project(RR tto_dicttupdatetgetattrRthasattrR	tstrtimeR2tFalsetTrue(Rtvalues((s3/usr/lib/python2.7/dist-packages/contego/context.pyRFs&	%		cCs”tt|ƒj|d|jdƒd|jdƒd|jddƒd|jdƒd|jdƒd|jdƒd|jdƒd	|jd	tƒƒS(
NR7R8R+R!R,R2R5RR4(RR t	from_dictR3RK(tclsRM((s3/usr/lib/python2.7/dist-packages/contego/context.pyRN«scCsktj|ƒ}tj|jƒ|_t|_d|jkrO|jjdƒn|dk	rg||_n|S(s5Return a version of this context with admin flag set.tadminN(tcopytdeepcopytrolesRLR$tappendRR+(RR+R((s3/usr/lib/python2.7/dist-packages/contego/context.pytelevated¼s	cCsh|dkr)i|jd6|jd6}nytj|||ƒSWn!tjk
rc|r_‚ntSXdS(sRVerifies 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.
        R8R7N(RR8R7tpolicyt	authorizeRt	ForbiddenRK(Rtactionttargettfatal((s3/usr/lib/python2.7/dist-packages/contego/context.pytcanÌs
cCsd|jƒS(Ns<Context %s>(RF(R((s3/usr/lib/python2.7/dist-packages/contego/context.pyt__str__ðsN(RRRRRKRR:R<R@RAtpropertyR+RFtclassmethodRNRURLR\R](((s3/usr/lib/python2.7/dist-packages/contego/context.pyR :s 		5							$c	CstdddddtdtƒS(s·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.
    R7R8R$t	overwriteN(R RRK(((s3/usr/lib/python2.7/dist-packages/contego/context.pytget_contextôsR!cCs%tdddddtd|dtƒS(NR7R8R$R+R`(R RRLRK(R+((s3/usr/lib/python2.7/dist-packages/contego/context.pytget_admin_contexts
cCs3|s
tS|jrtS|js+|jr/tStS(s2Indicates if the request context is a normal user.(RKR$R7R8RL(R((s3/usr/lib/python2.7/dist-packages/contego/context.pytis_user_contexts	cCs*|jr&t|ƒr&tjƒ‚ndS(sRRaise exception.Forbidden() if context is not a user or an
    admin context.
    N(R$RcRRX(tctxt((s3/usr/lib/python2.7/dist-packages/contego/context.pytrequire_contextscCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(s=Ensures a request has permission to access the given project.N(RcR8RRX(RR8((s3/usr/lib/python2.7/dist-packages/contego/context.pytauthorize_project_context!s
	cCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(s:Ensures a request has permission to access the given user.N(RcR7RRX(RR7((s3/usr/lib/python2.7/dist-packages/contego/context.pytauthorize_user_context*s
	cCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(sAEnsures a request has permission to access the given quota class.N(RcR5RRX(Rt
class_name((s3/usr/lib/python2.7/dist-packages/contego/context.pytauthorize_quota_class_context3s
	()RRQt
contextlibRtkeystoneauth1.accessRRt
keystoneauth1Rtoslo_contextRtoslo_db.sqlalchemyRtoslo_logRtloggingt
oslo_utilsRR/tcontegoRtcontego.i18nRR	t	getLoggerRtLOGtobjecttdid_not_respond_sentineltraised_exception_sentineltBaseAuthPluginR
ttransaction_context_providerR RaRbRcReRfRgRi(((s3/usr/lib/python2.7/dist-packages/contego/context.pyt<module>s2			¹