isAuthorized
inline suspend fun VerifiedPermissionsClient.isAuthorized(crossinline block: IsAuthorizedRequest.Builder.() -> Unit): IsAuthorizedResponse
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.
Samples
import aws.sdk.kotlin.services.verifiedpermissions.model.ActionIdentifier
import aws.sdk.kotlin.services.verifiedpermissions.model.EntityIdentifier
fun main() {
//sampleStart
// The following example requests an authorization decision for a principal of type User named Alice,
// who wants to perform the updatePhoto operation, on a resource of type Photo named VacationPhoto94. jpg.
// The response shows that the request was allowed by one policy.
val resp = verifiedPermissionsClient.isAuthorized {
principal = EntityIdentifier {
entityType = "User"
entityId = "alice"
}
action = ActionIdentifier {
actionType = "Action"
actionId = "view"
}
resource = EntityIdentifier {
entityType = "Photo"
entityId = "VacationPhoto94.jpg"
}
policyStoreId = "C7v5xMplfFH3i3e4Jrzb1a"
}
//sampleEnd
}
import aws.sdk.kotlin.services.verifiedpermissions.model.ActionIdentifier
import aws.sdk.kotlin.services.verifiedpermissions.model.EntityIdentifier
fun main() {
//sampleStart
// The following example is the same as the previous example, except that the principal is User "bob",
// and the policy store doesn t contain any policy that allows that user access to Album "alice_folder".
// The output infers that the Deny was implicit because the list of DeterminingPolicies is empty.
val resp = verifiedPermissionsClient.isAuthorized {
principal = EntityIdentifier {
entityType = "User"
entityId = "bob"
}
action = ActionIdentifier {
actionType = "Action"
actionId = "view"
}
resource = EntityIdentifier {
entityType = "Photo"
entityId = "VacationPhoto94.jpg"
}
policyStoreId = "C7v5xMplfFH3i3e4Jrzb1a"
}
//sampleEnd
}