CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.7 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.7
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • AbstractPasswordHasher
  • ActionsAuthorize
  • BaseAuthenticate
  • BaseAuthorize
  • BasicAuthenticate
  • BlowfishAuthenticate
  • BlowfishPasswordHasher
  • ControllerAuthorize
  • CrudAuthorize
  • DigestAuthenticate
  • FormAuthenticate
  • SimplePasswordHasher

Class ControllerAuthorize

An authorization adapter for AuthComponent. Provides the ability to authorize using a controller callback. Your controller's isAuthorized() method should return a boolean to indicate whether or not the user is authorized.

public function isAuthorized($user) {
    if (!empty($this->request->params['admin'])) {
        return $user['role'] === 'admin';
    }
    return !empty($user);
}

the above is simple implementation that would only authorize users of the 'admin' role to access admin routing.

BaseAuthorize
Extended by ControllerAuthorize
Package: Cake\Controller\Component\Auth
Since: 2.0
See: AuthComponent::$authenticate
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Controller/Component/Auth/ControllerAuthorize.php

Inherited Properties

  • _Collection, _Controller, settings

Method Summary

  • authorize() public
    Checks user authorization using a controller callback.
  • controller() public
    Get/set the controller this authorize object will be working with. Also checks that isAuthorized is implemented.

Method Detail

authorize() public ¶

authorize( array $user , CakeRequest $request )

Checks user authorization using a controller callback.

Parameters
array $user
Active user data
CakeRequest $request
Request instance.
Returns
boolean

controller() public ¶

controller( Controller $controller = null )

Get/set the controller this authorize object will be working with. Also checks that isAuthorized is implemented.

Parameters
Controller $controller optional null
null to get, a controller to set.
Returns
mixed
Throws
CakeException
Overrides
BaseAuthorize::controller()

Methods inherited from BaseAuthorize

__construct() public ¶

__construct( ComponentCollection $collection , string $settings = array() )

Constructor

Parameters
ComponentCollection $collection
The controller for this request.
string $settings optional array()
An array of settings. This class does not use any settings.

action() 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
string
the action path for the given request.

mapActions() 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
mixed
Either the current mappings or null when setting.
See
AuthComponent::mapActions()
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs