/ cake / libs / controller / components / security.php

Defined Classes

SecurityComponent Class Info:

Class Declaration:

class SecurityComponent extends Object

File name:
cake/libs/controller/components/security.php
Description:

SecurityComponent

Class Inheritance

Object

Properties:

Show/Hide parent properties
  • _action string

    Holds the current action of the controller

  • allowedActions array

    Actions from which actions of the current controller are allowed to receive requests.

  • allowedControllers array

    Controllers from which actions of the current controller are allowed to receive requests.

  • blackHoleCallback string

    The controller method that will be called if this request is black-hole'd

  • components array

    Other components used by the Security component

  • disabledFields array

    Form fields to disable

  • loginOptions array

  • loginUsers array

    An associative array of usernames/passwords used for HTTP-authenticated logins.

  • requireAuth array

    List of actions that require a valid authentication key

  • requireDelete array

    List of controller actions for which a DELETE request is required

  • requireGet array

    List of controller actions for which a GET request is required

  • requireLogin array

    List of actions that require an HTTP-authenticated login (basic or digest)

  • requirePost array

    List of controller actions for which a POST request is required

  • requirePut array

    List of controller actions for which a PUT request is required

  • requireSecure array

    List of actions that require an SSL-secured connection

  • validatePost boolean

    Whether to validate POST data. Set to false to disable for data coming from 3rd party services, etc.

_authRequired

top

Check if authentication is required

Parameters:
  • object $controller required

    Instantiating controller

Method defined in:
cake/libs/controller/components/security.php on line 509
Return

bool true if authentication required

Access

protected

blackHole

top

Black-hole an invalid request with a 404 error or custom callback. If SecurityComponent::$blackHoleCallback is specified, it will use this callback by executing the method indicated in $error

Parameters:
  • object $controller required

    Instantiating controller

  • string $error optional ''

    Error method

Method defined in:
cake/libs/controller/components/security.php on line 427
Return

mixed If specified, controller blackHoleCallback's response, or no return otherwise

Access

public

See

SecurityComponent::$blackHoleCallback

Link
http://book.cakephp.org/view/1307/blackHole-object-controller-string-error

cakeError

top

Used to report user friendly errors. If there is a file app/error.php or app/app_error.php this file will be loaded error.php is the AppError class it should extend ErrorHandler class.

Parameters:
  • string $method required

    Method to be called in the error class (AppError or ErrorHandler classes)

  • array $messages optional array ( )

    Message that is to be displayed by the error class

Method defined in:
cake/libs/object.php on line 187
Return

error message

Access

public

_callback

top

Calls a controller callback method

Parameters:
  • object $controller required

    Controller to run callback on

  • string $method required

    Method to execute

  • array $params optional array ( )

    Parameters to send to method

Method defined in:
cake/libs/controller/components/security.php on line 739
Return

mixed Controller callback method's response

Access

protected

__construct

top

Class constructor, overridden in descendant classes.

Method defined in:
cake/libs/object.php on line 54

dispatchMethod

top

Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array

Parameters:
  • string $method required

    Name of the method to call

  • array $params optional array ( )

    Parameter list to use when calling $method

Method defined in:
cake/libs/object.php on line 107
Return

mixed Returns the result of the method call

Access

public

generateDigestResponseHash

top

Generates a hash to be compared with an HTTP digest-authenticated response

Parameters:
Method defined in:
cake/libs/controller/components/security.php on line 408

_generateToken

top

Add authentication key for new form posts

Parameters:
  • object $controller required

    Instantiating controller

Method defined in:
cake/libs/controller/components/security.php on line 674
Return

bool Success

Access

protected

initialize

top

Initialize the SecurityComponent

Parameters:
  • object $controller required

    Controller instance for the request

  • array $settings optional array ( )

    Settings to set to the component

Method defined in:
cake/libs/controller/components/security.php on line 180
Return

void

Access

public

log

top

Convience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.

Parameters:
  • string $msg required

    Log message

  • integer $type optional 2

    Error type constant. Defined in app/config/core.php.

Method defined in:
cake/libs/object.php on line 148
Return

boolean Success of log write

Access

public

loginCredentials

top

Attempts to validate the login credentials for an HTTP-authenticated request

Parameters:
  • string $type optional NULL

    Either 'basic', 'digest', or null. If null/empty, will try both.

Method defined in:
cake/libs/controller/components/security.php on line 316
Return

mixed If successful, returns an array with login name and password, otherwise null.

Access

public

Link
http://book.cakephp.org/view/1303/loginCredentials-string-type

loginRequest

top

Generates the text of an HTTP-authentication request header from an array of options.

Parameters:
  • array $options optional array ( )

    Set of options for header

Method defined in:
cake/libs/controller/components/security.php on line 356
Return

string HTTP-authentication request header

Access

public

Link
http://book.cakephp.org/view/1304/loginRequest-array-options

_loginRequired

top

Check if login is required

Parameters:
  • object $controller required

    Instantiating controller

Method defined in:
cake/libs/controller/components/security.php on line 545
Return

bool true if login is required

Access

protected

_methodsRequired

top

Check if HTTP methods are required

Parameters:
  • object $controller required

    Instantiating controller

Method defined in:
cake/libs/controller/components/security.php on line 462
Return

bool true if $method is required

Access

protected

Object

top

A hack to support __construct() on PHP 4 Hint: descendant classes have no PHP4 class_name() constructors, so this constructor gets called first and calls the top-layer __construct() which (if present) should call parent::__construct()

Method defined in:
cake/libs/object.php on line 43
Return

Object

parseDigestAuthData

top

Parses an HTTP digest authentication response, and returns an array of the data, or null on failure.

Parameters:
  • string $digest required

    Digest authentication response

Method defined in:
cake/libs/controller/components/security.php on line 379
Return

array Digest authentication parameters

Access

public

Link
http://book.cakephp.org/view/1305/parseDigestAuthData-string-digest

_persist

top

Checks for a persistent class file, if found file is opened and true returned If file is not found a file is created and false returned If used in other locations of the model you should choose a unique name for the persistent file There are many uses for this method, see manual for examples

Parameters:
  • string $name required

    name of the class to persist

  • $return required

  • string $object required

    the object to persist

  • $type optional NULL

Method defined in:
cake/libs/object.php on line 218
Return

boolean Success

Access

protected

Todo

add examples to manual

requestAction

top

Calls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.

Parameters:
  • mixed $url required

    String or array-based url.

  • array $extra optional array ( )

    if array includes the key "return" it sets the AutoRender to true.

Method defined in:
cake/libs/object.php on line 80
Return

mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.

Access

public

requireAuth

top

Sets the actions that require an authenticated request, or empty for all actions

Method defined in:
cake/libs/controller/components/security.php on line 278
Return

void

Access

public

Link
http://book.cakephp.org/view/1301/requireAuth

requireDelete

top

Sets the actions that require a DELETE request, or empty for all actions

Method defined in:
cake/libs/controller/components/security.php on line 254
Return

void

Access

public

requireGet

top

Sets the actions that require a GET request, or empty for all actions

Method defined in:
cake/libs/controller/components/security.php on line 232
Return

void

Access

public

requireLogin

top

Sets the actions that require an HTTP-authenticated request, or empty for all actions

Method defined in:
cake/libs/controller/components/security.php on line 290
Return

void

Access

public

Link
http://book.cakephp.org/view/1302/requireLogin

_requireMethod

top

Sets the actions that require a $method HTTP request, or empty for all actions

Parameters:
  • string $method required

    The HTTP method to assign controller actions to

  • array $actions optional array ( )

    Controller actions to set the required HTTP method to.

Method defined in:
cake/libs/controller/components/security.php on line 448
Return

void

Access

protected

requirePost

top

Sets the actions that require a POST request, or empty for all actions

Method defined in:
cake/libs/controller/components/security.php on line 221
Return

void

Access

public

Link
http://book.cakephp.org/view/1299/requirePost

requirePut

top

Sets the actions that require a PUT request, or empty for all actions

Method defined in:
cake/libs/controller/components/security.php on line 243
Return

void

Access

public

requireSecure

top

Sets the actions that require a request that is SSL-secured, or empty for all actions

Method defined in:
cake/libs/controller/components/security.php on line 266
Return

void

Access

public

Link
http://book.cakephp.org/view/1300/requireSecure

_savePersistent

top

You should choose a unique name for the persistent file

There are many uses for this method, see manual for examples

Parameters:
  • string $name required

    name used for object to cache

  • object $object required

    the object to persist

Method defined in:
cake/libs/object.php on line 247
Return

boolean true on save, throws error if file can not be created

Access

protected

_secureRequired

top

Check if access requires secure connection

Parameters:
  • object $controller required

    Instantiating controller

Method defined in:
cake/libs/controller/components/security.php on line 487
Return

bool true if secure connection required

Access

protected

_set

top

Allows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.

Parameters:
  • array $properties optional array ( )

    An associative array containing properties and corresponding values.

Method defined in:
cake/libs/object.php on line 166
Return

void

Access

protected

_setLoginDefaults

top

Sets the default login options for an HTTP-authenticated request

Parameters:
  • array $options required

    Default login options

Method defined in:
cake/libs/controller/components/security.php on line 720
Return

void

Access

protected

startup

top

Component startup. All security checking happens here.

Parameters:
  • object $controller required

    Instantiating controller

Method defined in:
cake/libs/controller/components/security.php on line 191
Return

void

Access

public

_stop

top

Stop execution of the current script. Wraps exit() making testing easier.

Parameters:
  • $status optional 0

Method defined in:
cake/libs/object.php on line 135
Return

void

Access

public

toString

top

Object-to-string conversion. Each class can override this method as necessary.

Method defined in:
cake/libs/object.php on line 64
Return

string The name of this class

Access

public

_validatePost

top

Validate submitted form

Parameters:
  • object $controller required

    Instantiating controller

Method defined in:
cake/libs/controller/components/security.php on line 593
Return

bool true if submitted form is valid

Access

protected