batchIsAuthorizedWithToken method

Future<BatchIsAuthorizedWithTokenOutput> batchIsAuthorizedWithToken({
  1. required String policyStoreId,
  2. required List<BatchIsAuthorizedWithTokenInputItem> requests,
  3. String? accessToken,
  4. EntitiesDefinition? entities,
  5. String? identityToken,
})

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.

May throw ResourceNotFoundException.

Parameter 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.

Parameter requests : An array of up to 30 requests that you want Verified Permissions to evaluate.

Parameter accessToken : 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, an identityToken, or both.

Must be an access token. Verified Permissions returns an error if the token_use claim in the submitted token isn't access.

Parameter entities : (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.

  • The BatchIsAuthorizedWithToken operation takes principal attributes from only the identityToken or accessToken passed to the operation.
  • For action entities, you can include only their Identifier and EntityType.

Parameter identityToken : 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, an identityToken, or both.

Must be an ID token. Verified Permissions returns an error if the token_use claim in the submitted token isn't id.

Implementation

Future<BatchIsAuthorizedWithTokenOutput> batchIsAuthorizedWithToken({
  required String policyStoreId,
  required List<BatchIsAuthorizedWithTokenInputItem> requests,
  String? accessToken,
  EntitiesDefinition? entities,
  String? identityToken,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'VerifiedPermissions.BatchIsAuthorizedWithToken'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'policyStoreId': policyStoreId,
      'requests': requests,
      if (accessToken != null) 'accessToken': accessToken,
      if (entities != null) 'entities': entities,
      if (identityToken != null) 'identityToken': identityToken,
    },
  );

  return BatchIsAuthorizedWithTokenOutput.fromJson(jsonResponse.body);
}