check
fun <Resource : Any> check(principal: Principal, resource: Resource, vararg actions: ResourceAction<Resource>)
Checks that the action performed by the principal is allowed against the resource. Throws a PermissionDeniedException when the action is not allowed. Use this method when you wish to perform a permission check that throws an exception.
Parameters
principal
The principal attempting to access the resource.
action
The action being performed on the resource.
resource
The resource being accessed.
Throws
when the action is not allowed.
Utility for defining a block of permission checks.
For example:
policy.check {
User("owner").can(Document.read, document)
User("owner") can Document.write(document)
}
Content copied to clipboard