isAuthorized method
- required String policyStoreId,
- ActionIdentifier? action,
- ContextDefinition? context,
- EntitiesDefinition? entities,
- EntityIdentifier? principal,
- EntityIdentifier? resource,
Makes an authorization decision about a service request described in the
parameters. 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 or
Deny, along with a list of the policies that resulted in the
decision.
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
Parameter action :
Specifies the requested action to be authorized. For example, is the
principal authorized to perform this action on the resource?
Parameter context :
Specifies additional context that can be used to make more granular
authorization decisions.
Parameter entities :
(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.
Parameter principal :
Specifies the principal for which the authorization decision is to be
made.
Parameter resource :
Specifies the resource for which the authorization decision is to be made.
Implementation
Future<IsAuthorizedOutput> isAuthorized({
required String policyStoreId,
ActionIdentifier? action,
ContextDefinition? context,
EntitiesDefinition? entities,
EntityIdentifier? principal,
EntityIdentifier? resource,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'VerifiedPermissions.IsAuthorized'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'policyStoreId': policyStoreId,
if (action != null) 'action': action,
if (context != null) 'context': context,
if (entities != null) 'entities': entities,
if (principal != null) 'principal': principal,
if (resource != null) 'resource': resource,
},
);
return IsAuthorizedOutput.fromJson(jsonResponse.body);
}