本文整理匯總了Python中indy_common.auth.Authoriser.authorised方法的典型用法代碼示例。如果您正苦於以下問題:Python Authoriser.authorised方法的具體用法?Python Authoriser.authorised怎麽用?Python Authoriser.authorised使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類indy_common.auth.Authoriser
的用法示例。
在下文中一共展示了Authoriser.authorised方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: validate
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def validate(self, req: Request):
status = None
operation = req.operation
typ = operation.get(TXN_TYPE)
if typ not in self.operation_types:
return
origin = req.identifier
try:
origin_role = self.idrCache.getRole(origin, isCommitted=False)
except BaseException:
raise UnauthorizedClientRequest(
req.identifier,
req.reqId,
"Nym {} not added to the ledger yet".format(origin))
r = False
if typ == POOL_RESTART:
action = operation.get(ACTION)
r, msg = Authoriser.authorised(typ, origin_role,
field=ACTION,
oldVal=status,
newVal=action)
elif typ == VALIDATOR_INFO:
r, msg = Authoriser.authorised(typ, origin_role)
if not r:
raise UnauthorizedClientRequest(
req.identifier, req.reqId,
"{} cannot do action with type = {}".format(
Roles.nameFromValue(origin_role),
typ))
示例2: test_node_wrong_new_service_name
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_node_wrong_new_service_name(role, is_owner):
assert not Authoriser.authorised(typ=NODE,
actorRole=role,
field=SERVICES,
oldVal="[]",
newVal="aaa",
isActorOwnerOfSubject=is_owner)[0]
示例3: _validate_schema
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def _validate_schema(self, req: Request):
# we can not add a Schema with already existent NAME and VERSION
# sine a Schema needs to be identified by seqNo
identifier = req.identifier
operation = req.operation
schema_name = operation[DATA][NAME]
schema_version = operation[DATA][VERSION]
schema, _, _, _ = self.getSchema(
author=identifier,
schemaName=schema_name,
schemaVersion=schema_version,
with_proof=False
)
if schema:
raise InvalidClientRequest(identifier, req.reqId,
'{} can have one and only one SCHEMA with '
'name {} and version {}'
.format(identifier, schema_name, schema_version))
try:
origin_role = self.idrCache.getRole(
req.identifier, isCommitted=False) or None
except BaseException:
raise UnknownIdentifier(
req.identifier,
req.reqId)
r, msg = Authoriser.authorised(typ=SCHEMA,
actorRole=origin_role)
if not r:
raise UnauthorizedClientRequest(
req.identifier,
req.reqId,
"{} cannot add schema".format(
Roles.nameFromValue(origin_role))
)
示例4: _validateExistingNym
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def _validateExistingNym(self, req: Request, op, originRole, nymData):
unauthorized = False
reason = None
origin = req.identifier
owner = self.idrCache.getOwnerFor(op[TARGET_NYM], isCommitted=False)
isOwner = origin == owner
if not originRole == TRUSTEE and not isOwner:
reason = '{} is neither Trustee nor owner of {}' \
.format(origin, op[TARGET_NYM])
unauthorized = True
if not unauthorized:
updateKeys = [ROLE, VERKEY]
for key in updateKeys:
if key in op:
newVal = op[key]
oldVal = nymData.get(key)
if oldVal != newVal:
r, msg = Authoriser.authorised(NYM, key, originRole,
oldVal=oldVal, newVal=newVal,
isActorOwnerOfSubject=isOwner)
if not r:
unauthorized = True
reason = "{} cannot update {}".\
format(Roles.nameFromValue(originRole), key)
break
if unauthorized:
raise UnauthorizedClientRequest(
req.identifier, req.reqId, reason)
示例5: test_pool_upgrade_wrong_new_name
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_pool_upgrade_wrong_new_name(role, is_owner):
assert not Authoriser.authorised(typ=POOL_UPGRADE,
field=ACTION,
actorRole=role,
oldVal="start",
newVal="aaa",
isActorOwnerOfSubject=is_owner)[0]
示例6: test_pool_upgrade_start
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_pool_upgrade_start(role, is_owner):
authorized = role in (TRUSTEE, TGB)
assert authorized == Authoriser.authorised(typ=POOL_UPGRADE,
field=ACTION,
actorRole=role,
oldVal=None,
newVal="start",
isActorOwnerOfSubject=is_owner)[0]
示例7: test_node_change_bls_keys
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_node_change_bls_keys(role, is_owner, old_values):
authorized = (role == STEWARD and is_owner)
assert authorized == Authoriser.authorised(typ=NODE,
actorRole=role,
field=BLS_KEY,
oldVal=old_values,
newVal="value2",
isActorOwnerOfSubject=is_owner)[0]
示例8: test_pool_config_change
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_pool_config_change(role, is_owner, old_values):
authorized = role in (TRUSTEE, TGB)
assert authorized == Authoriser.authorised(typ=POOL_CONFIG,
actorRole=role,
field=ACTION,
oldVal=old_values,
newVal="value2",
isActorOwnerOfSubject=is_owner)[0]
示例9: test_node_enable
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_node_enable(role, is_owner):
authorized = (role == STEWARD and is_owner)
assert authorized == Authoriser.authorised(typ=NODE,
actorRole=role,
field=SERVICES,
oldVal=None,
newVal="[VALIDATOR]",
isActorOwnerOfSubject=is_owner)[0]
示例10: test_node_not_allowed_role_error
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_node_not_allowed_role_error():
expected_msg = "TRUSTEE not in allowed roles ['STEWARD']"
assert expected_msg == Authoriser.authorised(typ=NODE,
actorRole=TRUSTEE,
field=BLS_KEY,
oldVal=None,
newVal="some_value",
isActorOwnerOfSubject=False)[1]
示例11: test_remove_trust_anchor
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_remove_trust_anchor(role, is_owner):
authorized = (role == TRUSTEE)
assert authorized == Authoriser.authorised(typ=NYM,
actorRole=role,
field=ROLE,
oldVal=TRUST_ANCHOR,
newVal=None,
isActorOwnerOfSubject=is_owner)[0]
示例12: test_change_verkey
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_change_verkey(role, is_owner, old_values):
authorized = is_owner
assert authorized == Authoriser.authorised(typ=NYM,
actorRole=role,
field=VERKEY,
oldVal=old_values,
newVal="value2",
isActorOwnerOfSubject=is_owner)[0]
示例13: test_make_trustee
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_make_trustee(role, is_owner):
authorized = (role == TRUSTEE)
assert authorized == Authoriser.authorised(typ=NYM,
actorRole=role,
field=ROLE,
oldVal=None,
newVal=TRUSTEE,
isActorOwnerOfSubject=is_owner)[0]
示例14: test_remove_steward
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_remove_steward(role, is_owner):
authorized = (role == TRUSTEE)
assert authorized == Authoriser.authorised(typ=NYM,
actorRole=role,
field=ROLE,
oldVal=STEWARD,
newVal=None,
isActorOwnerOfSubject=is_owner)[0]
示例15: test_make_trust_anchor
# 需要導入模塊: from indy_common.auth import Authoriser [as 別名]
# 或者: from indy_common.auth.Authoriser import authorised [as 別名]
def test_make_trust_anchor(role, is_owner):
authorized = role in (TRUSTEE, STEWARD)
assert authorized == Authoriser.authorised(typ=NYM,
actorRole=role,
field=ROLE,
oldVal=None,
newVal=TRUST_ANCHOR,
isActorOwnerOfSubject=is_owner)[0]