NAME

Authorization::AccessControl::Request - constructs an ACL request and checks if it is accepted

SYNOPSIS

return unless(acl->request
  ->with_roles('admin')
  ->with_resource('Media')
  ->with_action('create')
  ->permitted);

acl->request...->yield(sub() { ... })
  ->granted(sub ($x) { ... })
  ->denied(sub() { ... })

DESCRIPTION

This class is used to construct a request and check if the ACL accepts it. The 4 with_* methods are used to configure it, with later calls to the same method overwriting previous ones (with the exception of with_attributes which merges instead).

"permitted" can be called directly, or via "yield", but either way, it will return false until "with_resource" and with_action have been called to configure it.

Request instances are immutable: none of their properties may be altered after object creation.

METHODS

with_roles

$req->with_roles( @roles )

Returns a new request instance with its roles property configured to match the parameter value.

Chainable.

with_action

$req->with_action( $action )

Returns a new request instance with its action property configured to match the parameter value.

Chainable.

with_resource

$req->with_resource( $resource )

Returns a new request instance with its resource property configured to match the parameter value.

Chainable.

with_attributes

$req->with_attributes( $attributes )

Returns a new request instance with its attributes property merged with the parameter value.

Chainable.

with_get_attrs

$req->with_get_attrs( sub($value) { ... } )

Returns a new request instance with its get_attrs property configured to match the parameter value. This is a callback that receives a protected data value (in "yield") and returns the corresponding dynamic attributes for it.

Chainable.

permitted

$req->permitted()

Returns a boolean value reflecting whether the request's configured properties satisfy the requirements for any grant in the ACL.

yield

$req->yield(sub() { ... })

Returns an Authorization::AccessControl::Disapatch instance corresponding to the data value returned by the callback and its permitted status.

AUTHOR

Mark Tyrrell <mark@tyrrminal.dev>

LICENSE

Copyright (c) 2024 Mark Tyrrell

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.