VerifiedPermissions / Client / is_authorized_with_token
is_authorized_with_token#
- VerifiedPermissions.Client.is_authorized_with_token(**kwargs)#
Makes an authorization decision about a service request described in the parameters. The principal in this request comes from an external identity source in the form of an identity token formatted as a JSON web token (JWT). The information in the parameters can also define additional context that Verified Permissions can include in the evaluation. The request is evaluated against all matching policies in the specified policy store. The result of the decision is either
Allow
orDeny
, along with a list of the policies that resulted in the decision.Warning
If you specify the
identityToken
parameter, then this operation derives the principal from that token. You must not also include that principal in theentities
parameter or the operation fails and reports a conflict between the two entity sources.If you provide only an
accessToken
, then you can include the entity as part of theentities
parameter to provide additional attributes.At this time, Verified Permissions accepts tokens from only Amazon Cognito.
Verified Permissions validates each token that is specified in a request by checking its expiration date and its signature.
Warning
If you delete a Amazon Cognito user pool or user, tokens from that deleted pool or that deleted user continue to be usable until they expire.
See also: AWS API Documentation
Request Syntax
response = client.is_authorized_with_token( policyStoreId='string', identityToken='string', accessToken='string', action={ 'actionType': 'string', 'actionId': 'string' }, resource={ 'entityType': 'string', 'entityId': 'string' }, context={ 'contextMap': { 'string': { 'boolean': True|False, 'entityIdentifier': { 'entityType': 'string', 'entityId': 'string' }, 'long': 123, 'string': 'string', 'set': [ {'... recursive ...'}, ], 'record': { 'string': {'... recursive ...'} } } } }, entities={ 'entityList': [ { 'identifier': { 'entityType': 'string', 'entityId': 'string' }, 'attributes': { 'string': { 'boolean': True|False, 'entityIdentifier': { 'entityType': 'string', 'entityId': 'string' }, 'long': 123, 'string': 'string', 'set': [ {'... recursive ...'}, ], 'record': { 'string': {'... recursive ...'} } } }, 'parents': [ { 'entityType': 'string', 'entityId': 'string' }, ] }, ] } )
- Parameters:
policyStoreId (string) –
[REQUIRED]
Specifies the ID of the policy store. Policies in this policy store will be used to make an authorization decision for the input.
identityToken (string) – Specifies an identity token for the principal to be authorized. This token is provided to you by the identity provider (IdP) associated with the specified identity source. You must specify either an
AccessToken
or anIdentityToken
, or both.accessToken (string) – Specifies an access token for the principal to be authorized. This token is provided to you by the identity provider (IdP) associated with the specified identity source. You must specify either an
AccessToken
, or anIdentityToken
, or both.action (dict) –
Specifies the requested action to be authorized. Is the specified principal authorized to perform this action on the specified resource.
actionType (string) – [REQUIRED]
The type of an action.
actionId (string) – [REQUIRED]
The ID of an action.
resource (dict) –
Specifies the resource for which the authorization decision is made. For example, is the principal allowed to perform the action on the resource?
entityType (string) – [REQUIRED]
The type of an entity.
Example:
"entityType":"typeName"
entityId (string) – [REQUIRED]
The identifier of an entity.
"entityId":"identifier"
context (dict) –
Specifies additional context that can be used to make more granular authorization decisions.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
contextMap
.contextMap (dict) –
An list of attributes that are needed to successfully evaluate an authorization request. Each attribute in this array must include a map of a data type and its value.
Example:
"Context":{"<KeyName1>":{"boolean":true},"<KeyName2>":{"long":1234}}
(string) –
(dict) –
The value of an attribute.
Contains information about the runtime context for a request for which an authorization decision is made.
This data type is used as a member of the ContextDefinition structure which is uses as a request parameter for the IsAuthorized and IsAuthorizedWithToken operations.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
boolean
,entityIdentifier
,long
,string
,set
,record
.boolean (boolean) –
An attribute value of Boolean type.
Example:
{"boolean": true}
entityIdentifier (dict) –
An attribute value of type EntityIdentifier.
Example:
"entityIdentifier": { "entityId": "<id>", "entityType": "<entity type>"}
entityType (string) – [REQUIRED]
The type of an entity.
Example:
"entityType":"typeName"
entityId (string) – [REQUIRED]
The identifier of an entity.
"entityId":"identifier"
long (integer) –
An attribute value of Long type.
Example:
{"long": 0}
string (string) –
An attribute value of String type.
Example:
{"string": "abc"}
set (list) –
An attribute value of Set type.
Example:
{"set": [ {} ] }
(dict) –
The value of an attribute.
Contains information about the runtime context for a request for which an authorization decision is made.
This data type is used as a member of the ContextDefinition structure which is uses as a request parameter for the IsAuthorized and IsAuthorizedWithToken operations.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
boolean
,entityIdentifier
,long
,string
,set
,record
.
record (dict) –
An attribute value of Record type.
Example:
{"record": { "keyName": {} } }
(string) –
(dict) –
The value of an attribute.
Contains information about the runtime context for a request for which an authorization decision is made.
This data type is used as a member of the ContextDefinition structure which is uses as a request parameter for the IsAuthorized and IsAuthorizedWithToken operations.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
boolean
,entityIdentifier
,long
,string
,set
,record
.
entities (dict) –
Specifies the list of resources and their associated attributes that Verified Permissions can examine when evaluating the policies.
Note
You can include only resource and action entities in this parameter; you can’t include principals.
The
IsAuthorizedWithToken
operation takes principal attributes from only theidentityToken
oraccessToken
passed to the operation.For action entities, you can include only their
Identifier
andEntityType
.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
entityList
.entityList (list) –
An array of entities that are needed to successfully evaluate an authorization request. Each entity in this array must include an identifier for the entity, the attributes of the entity, and a list of any parent entities.
(dict) –
Contains information about an entity that can be referenced in a Cedar policy.
This data type is used as one of the fields in the EntitiesDefinition structure.
{ "identifier": { "entityType": "Photo", "entityId": "VacationPhoto94.jpg" }, "attributes": {}, "parents": [ { "entityType": "Album", "entityId": "alice_folder" } ] }
identifier (dict) – [REQUIRED]
The identifier of the entity.
entityType (string) – [REQUIRED]
The type of an entity.
Example:
"entityType":"typeName"
entityId (string) – [REQUIRED]
The identifier of an entity.
"entityId":"identifier"
attributes (dict) –
A list of attributes for the entity.
(string) –
(dict) –
The value of an attribute.
Contains information about the runtime context for a request for which an authorization decision is made.
This data type is used as a member of the ContextDefinition structure which is uses as a request parameter for the IsAuthorized and IsAuthorizedWithToken operations.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
boolean
,entityIdentifier
,long
,string
,set
,record
.boolean (boolean) –
An attribute value of Boolean type.
Example:
{"boolean": true}
entityIdentifier (dict) –
An attribute value of type EntityIdentifier.
Example:
"entityIdentifier": { "entityId": "<id>", "entityType": "<entity type>"}
entityType (string) – [REQUIRED]
The type of an entity.
Example:
"entityType":"typeName"
entityId (string) – [REQUIRED]
The identifier of an entity.
"entityId":"identifier"
long (integer) –
An attribute value of Long type.
Example:
{"long": 0}
string (string) –
An attribute value of String type.
Example:
{"string": "abc"}
set (list) –
An attribute value of Set type.
Example:
{"set": [ {} ] }
(dict) –
The value of an attribute.
Contains information about the runtime context for a request for which an authorization decision is made.
This data type is used as a member of the ContextDefinition structure which is uses as a request parameter for the IsAuthorized and IsAuthorizedWithToken operations.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
boolean
,entityIdentifier
,long
,string
,set
,record
.
record (dict) –
An attribute value of Record type.
Example:
{"record": { "keyName": {} } }
(string) –
(dict) –
The value of an attribute.
Contains information about the runtime context for a request for which an authorization decision is made.
This data type is used as a member of the ContextDefinition structure which is uses as a request parameter for the IsAuthorized and IsAuthorizedWithToken operations.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
boolean
,entityIdentifier
,long
,string
,set
,record
.
parents (list) –
The parents in the hierarchy that contains the entity.
(dict) –
Contains the identifier of an entity, including its ID and type.
This data type is used as a request parameter for IsAuthorized operation, and as a response parameter for the CreatePolicy, GetPolicy, and UpdatePolicy operations.
Example:
{"entityId":"string","entityType":"string"}
entityType (string) – [REQUIRED]
The type of an entity.
Example:
"entityType":"typeName"
entityId (string) – [REQUIRED]
The identifier of an entity.
"entityId":"identifier"
- Return type:
dict
- Returns:
Response Syntax
{ 'decision': 'ALLOW'|'DENY', 'determiningPolicies': [ { 'policyId': 'string' }, ], 'errors': [ { 'errorDescription': 'string' }, ] }
Response Structure
(dict) –
decision (string) –
An authorization decision that indicates if the authorization request should be allowed or denied.
determiningPolicies (list) –
The list of determining policies used to make the authorization decision. For example, if there are multiple matching policies, where at least one is a forbid policy, then because forbid always overrides permit the forbid policies are the determining policies. If all matching policies are permit policies, then those policies are the determining policies. When no policies match and the response is the default DENY, there are no determining policies.
(dict) –
Contains information about one of the policies that determined an authorization decision.
This data type is used as an element in a response parameter for the IsAuthorized and IsAuthorizedWithToken operations.
Example:
"determiningPolicies":[{"policyId":"SPEXAMPLEabcdefg111111"}]
policyId (string) –
The Id of a policy that determined to an authorization decision.
Example:
"policyId":"SPEXAMPLEabcdefg111111"
errors (list) –
Errors that occurred while making an authorization decision. For example, a policy references an entity or entity attribute that does not exist in the slice.
(dict) –
Contains a description of an evaluation error.
This data type is used as a request parameter in the IsAuthorized and IsAuthorizedWithToken operations.
errorDescription (string) –
The error description.
Exceptions
VerifiedPermissions.Client.exceptions.ValidationException
VerifiedPermissions.Client.exceptions.AccessDeniedException
VerifiedPermissions.Client.exceptions.ResourceNotFoundException
VerifiedPermissions.Client.exceptions.ThrottlingException
VerifiedPermissions.Client.exceptions.InternalServerException