batch_is_authorized_with_token
¶
batch_is_authorized_with_token(
policy_store_id: PolicyStoreId,
requests: BatchIsAuthorizedWithTokenInputList,
*,
config_overrides: Optional[VerifiedPermissionsClientConfig] = None,
identity_token: Optional[Token] = None,
access_token: Optional[Token] = None,
entities: Optional[EntitiesDefinition] = None,
) -> BatchIsAuthorizedWithTokenOutput
Makes a series of decisions about multiple authorization requests for one token. The principal in this request comes from an external identity source in the form of an identity or access 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 evaluations.
The request is evaluated against all policies in the specified policy store that match the entities that you provide in the entities declaration and in the token. The result of the decisions is a series of Allow or Deny responses, along with the IDs of the policies that produced each decision.
The entities of a BatchIsAuthorizedWithToken API request can contain up to 100 resources and up to 99 user groups. The requests of a BatchIsAuthorizedWithToken API request can contain up to 30 requests.
The BatchIsAuthorizedWithToken operation doesn't have its own IAM permission. To authorize this operation for Amazon Web Services principals, include the permission verifiedpermissions:IsAuthorizedWithToken in their IAM policies.
Parameters:
-
policy_store_id(PolicyStoreId) –Specifies the ID of the policy store. Policies in this policy store will be used to make an authorization decision for the input.
To specify a policy store, use its ID or alias name. When using an alias name, prefix it with
policy-store-alias/. For example:-
ID:
PSEXAMPLEabcdefg111111 -
Alias name:
policy-store-alias/example-policy-store
To view aliases, use ListPolicyStoreAliases.
-
-
identity_token(Optional[Token], default:None) –Specifies an identity (ID) token for the principal that you want to authorize in each request. This token is provided to you by the identity provider (IdP) associated with the specified identity source. You must specify either an
accessToken, anidentityToken, or both.Must be an ID token. Verified Permissions returns an error if the
token_useclaim in the submitted token isn'tid. -
access_token(Optional[Token], default:None) –Specifies an access token for the principal that you want to authorize in each request. This token is provided to you by the identity provider (IdP) associated with the specified identity source. You must specify either an
accessToken, anidentityToken, or both.Must be an access token. Verified Permissions returns an error if the
token_useclaim in the submitted token isn'taccess. -
entities(Optional[EntitiesDefinition], default:None) –(Optional) Specifies the list of resources and their associated attributes that Verified Permissions can examine when evaluating the policies. These additional entities and their attributes can be referenced and checked by conditional elements in the policies in the specified policy store.
You can't include principals in this parameter, only resource and action entities. This parameter can't include any entities of a type that matches the user or group entity types that you defined in your identity source.
-
The
BatchIsAuthorizedWithTokenoperation takes principal attributes from only theidentityTokenoraccessTokenpassed to the operation. -
For action entities, you can include only their
IdentifierandEntityType.
-
-
requests(BatchIsAuthorizedWithTokenInputList) –An array of up to 30 requests that you want Verified Permissions to evaluate.
Raises:
-
AccessDeniedException–You don't have sufficient access to perform this action.
-
InternalServerException–The request failed because of an internal error. Try your request again later
-
ThrottlingException–The request failed because it exceeded a throttling quota.
-
ValidationException–The request failed because one or more input parameters don't satisfy their constraint requirements. The output is provided as a list of fields and a reason for each field that isn't valid.
The possible reasons include the following:
-
UnrecognizedEntityType
The policy includes an entity type that isn't found in the schema.
-
UnrecognizedActionId
The policy includes an action id that isn't found in the schema.
-
InvalidActionApplication
The policy includes an action that, according to the schema, doesn't support the specified principal and resource.
-
UnexpectedType
The policy included an operand that isn't a valid type for the specified operation.
-
IncompatibleTypes
The types of elements included in a
set, or the types of expressions used in anif...then...elseclause aren't compatible in this context. -
MissingAttribute
The policy attempts to access a record or entity attribute that isn't specified in the schema. Test for the existence of the attribute first before attempting to access its value. For more information, see the has (presence of attribute test) operator in the Cedar Policy Language Guide.
-
UnsafeOptionalAttributeAccess
The policy attempts to access a record or entity attribute that is optional and isn't guaranteed to be present. Test for the existence of the attribute first before attempting to access its value. For more information, see the has (presence of attribute test) operator in the Cedar Policy Language Guide.
-
ImpossiblePolicy
Cedar has determined that a policy condition always evaluates to false. If the policy is always false, it can never apply to any query, and so it can never affect an authorization decision.
-
WrongNumberArguments
The policy references an extension type with the wrong number of arguments.
-
FunctionArgumentValidationError
Cedar couldn't parse the argument passed to an extension type. For example, a string that is to be parsed as an IPv4 address can contain only digits and the period character.
-
-
ResourceNotFoundException–The request failed because it references a resource that doesn't exist.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Batch - Example 1 The following example requests three authorization decisions for two resources and two actions in different photo albums.
>>> client.batch_is_authorized_with_token(identity_token='eyJra12345EXAMPLE', requests=[{'action': {'actionType': 'PhotoFlash::Action', 'actionId': 'ViewPhoto'}, 'resource': {'entityType': 'PhotoFlash::Photo', 'entityId': 'VacationPhoto94.jpg'}}, {'action': {'actionType': 'PhotoFlash::Action', 'actionId': 'SharePhoto'}, 'resource': {'entityType': 'PhotoFlash::Photo', 'entityId': 'VacationPhoto94.jpg'}}, {'action': {'actionType': 'PhotoFlash::Action', 'actionId': 'ViewPhoto'}, 'resource': {'entityType': 'PhotoFlash::Photo', 'entityId': 'OfficePhoto94.jpg'}}], entities={'entityList': [{'identifier': {'entityType': 'PhotoFlash::Photo', 'entityId': 'VacationPhoto94.jpg'}, 'parents': [{'entityType': 'PhotoFlash::Album', 'entityId': 'MyExampleAlbum1'}]}, {'identifier': {'entityType': 'PhotoFlash::Photo', 'entityId': 'OfficePhoto94.jpg'}, 'parents': [{'entityType': 'PhotoFlash::Album', 'entityId': 'MyExampleAlbum2'}]}]}, policy_store_id='C7v5xMplfFH3i3e4Jrzb1a')
Source code in docs_src/capo_verifiedpermissions/_services/verified_permissions.py
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | |