batch_is_authorized
¶
batch_is_authorized(
policy_store_id: PolicyStoreId,
requests: BatchIsAuthorizedInputList,
*,
config_overrides: Optional[VerifiedPermissionsClientConfig] = None,
entities: Optional[EntitiesDefinition] = None,
) -> BatchIsAuthorizedOutput
Makes a series of decisions about multiple authorization requests for one principal or resource. Each request contains the equivalent content of an IsAuthorized request: principal, action, resource, and context. Either the principal or the resource parameter must be identical across all requests. For example, Verified Permissions won't evaluate a pair of requests where bob views photo1 and alice views photo2. Authorization of bob to view photo1 and photo2, or bob and alice to view photo1, are valid batches.
The request is evaluated against all policies in the specified policy store that match the entities that you declare. 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 BatchIsAuthorized API request can contain up to 100 principals and up to 100 resources. The requests of a BatchIsAuthorized API request can contain up to 30 requests.
The BatchIsAuthorized operation doesn't have its own IAM permission. To authorize this operation for Amazon Web Services principals, include the permission verifiedpermissions:IsAuthorized 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 the authorization decisions 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.
-
-
entities(Optional[EntitiesDefinition], default:None) –(Optional) Specifies the list of resources and principals 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 include only principal and resource entities in this parameter; you can't include actions. You must specify actions in the schema.
-
requests(BatchIsAuthorizedInputList) –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 two authorization decisions for two principals of type Usernamed Alice and Annalisa.
>>> client.batch_is_authorized(requests=[{'principal': {'entityType': 'PhotoFlash::User', 'entityId': 'Alice'}, 'action': {'actionType': 'PhotoFlash::Action', 'actionId': 'ViewPhoto'}, 'resource': {'entityType': 'PhotoFlash::Photo', 'entityId': 'VacationPhoto94.jpg'}}, {'principal': {'entityType': 'PhotoFlash::User', 'entityId': 'Annalisa'}, 'action': {'actionType': 'PhotoFlash::Action', 'actionId': 'DeletePhoto'}, 'resource': {'entityType': 'PhotoFlash::Photo', 'entityId': 'VacationPhoto94.jpg'}}], entities={'entityList': [{'identifier': {'entityType': 'PhotoFlash::User', 'entityId': 'Alice'}, 'attributes': {'Account': {'entityIdentifier': {'entityType': 'PhotoFlash::Account', 'entityId': '1234'}}, 'Email': {'string': ''}}, 'parents': []}, {'identifier': {'entityType': 'PhotoFlash::User', 'entityId': 'Annalisa'}, 'attributes': {'Account': {'entityIdentifier': {'entityType': 'PhotoFlash::Account', 'entityId': '5678'}}, 'Email': {'string': ''}}, 'parents': []}, {'identifier': {'entityType': 'PhotoFlash::Photo', 'entityId': 'VacationPhoto94.jpg'}, 'attributes': {'IsPrivate': {'boolean': False}, 'Name': {'string': ''}}, 'parents': [{'entityType': 'PhotoFlash::Account', 'entityId': '1234'}]}, {'identifier': {'entityType': 'PhotoFlash::Account', 'entityId': '1234'}, 'attributes': {'Name': {'string': ''}}, 'parents': []}]}, policy_store_id='C7v5xMplfFH3i3e4Jrzb1a')
Source code in docs_src/capo_verifiedpermissions/_services/verified_permissions.py
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 | |