Class CrudAuthorize
An authorization adapter for AuthComponent. Provides the ability to authorize using CRUD mappings. CRUD mappings allow you to translate controller actions into Create Read Update Delete actions. This is then checked in the AclComponent as specific permissions.
For example, taking /posts/index
as the current request. The default mapping for index
, is a read
permission check. The Acl check would then be for the posts
controller with the read
permission. This allows you to create permission systems that focus more on what is being done to resources, rather than the specific actions being visited.
- BaseAuthorize
- CrudAuthorize
Since: 2.0
See: AuthComponent::$authenticate
See: AclComponent::check()
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Controller/Component/Auth/CrudAuthorize.php
Inherited Properties
Method Summary
- __construct() publicSets up additional actionMap values that match the configured
Routing.prefixes
. - _setPrefixMappings() protectedsets the crud mappings for prefix routes.
- authorize() publicAuthorize a user using the mapped actions and the AclComponent.
Method Detail
__construct()source public
__construct( ComponentCollection $collection , string $settings array() )
Sets up additional actionMap values that match the configured Routing.prefixes
.
Parameters
-
ComponentCollection
$collection
- The component collection from the controller.
- string
$settings
optional array() - An array of settings. This class does not use any settings.
Overrides
BaseAuthorize::__construct()
_setPrefixMappings()source protected
_setPrefixMappings( )
sets the crud mappings for prefix routes.
authorize()source public
authorize( array $user , CakeRequest $request )
Authorize a user using the mapped actions and the AclComponent.
Parameters
- array
$user
- The user to authorize
-
CakeRequest
$request
- The request needing authorization.
Returns
booleanMethods inherited from BaseAuthorize
action()source public
action( CakeRequest $request , string $path '/:plugin/:controller/:action' )
Get the action path for a given request. Primarily used by authorize objects that need to get information about the plugin, controller, and action being invoked.
Parameters
-
CakeRequest
$request
- The request a path is needed for.
- string
$path
optional '/:plugin/:controller/:action' - Path format.
Returns
stringthe action path for the given request.
controller()source public
controller( Controller $controller null )
Accessor to the controller object.
Parameters
-
Controller
$controller
optional null - null to get, a controller to set.
Returns
mixedThrows
CakeException
mapActions()source public
mapActions( array $map array() )
Maps crud actions to actual action names. Used to modify or get the current mapped actions.
Create additional mappings for a standard CRUD operation:
$this->Auth->mapActions(array('create' => array('add', 'register'));
Or equivalently:
$this->Auth->mapActions(array('register' => 'create', 'add' => 'create'));
Create mappings for custom CRUD operations:
$this->Auth->mapActions(array('range' => 'search'));
You can use the custom CRUD operations to create additional generic permissions that behave like CRUD operations. Doing this will require additional columns on the permissions lookup. For example if one wanted an additional search CRUD operation one would create and additional column '_search' in the aros_acos table. One could create a custom admin CRUD operation for administration functions similarly if needed.
Parameters
- array
$map
optional array() - Either an array of mappings, or undefined to get current values.
Returns
mixedEither the current mappings or null when setting.
See
AuthComponent::mapActions()
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.10/class-CrudAuthorize.html