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.1 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.1
      • 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
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • ActionsAuthorize
  • BaseAuthenticate
  • BaseAuthorize
  • BasicAuthenticate
  • ControllerAuthorize
  • CrudAuthorize
  • DigestAuthenticate
  • FormAuthenticate

Class BasicAuthenticate

Basic Authentication adapter for AuthComponent.

Provides Basic HTTP authentication support for AuthComponent. Basic Auth will authenticate users against the configured userModel and verify the username and passwords match. Clients using Basic Authentication must support cookies. Since AuthComponent identifies users based on Session contents, clients using Basic Auth must support cookies.

Using Basic auth

In your controller's components array, add auth + the required settings. {{{ public $components = array( 'Auth' => array( 'authenticate' => array('Basic') ) ); }}}

In your login function just call $this->Auth->login() without any checks for POST data. This will send the authentication headers, and trigger the login dialog in the browser/client.

BaseAuthenticate
Extended by BasicAuthenticate
Package: Cake\Controller\Component\Auth
Since: 2.0
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/Controller/Component/Auth/BasicAuthenticate.php

Properties summary

  • $settings public
    array
    Settings for this object.

Inherited Properties

  • _Collection

Method Summary

  • __construct() public
    Constructor, completes configuration for basic authentication.
  • authenticate() public

    Authenticate a user using basic HTTP auth. Will use the configured User model and attempt a login using basic HTTP auth.

  • getUser() public
    Get a user based on information in the request. Used by cookie-less auth for stateless clients.
  • loginHeaders() public
    Generate the login headers

Method Detail

__construct() public ¶

__construct( ComponentCollection $collection , array $settings )

Constructor, completes configuration for basic authentication.

Parameters
ComponentCollection $collection
The Component collection used on this request.
array $settings
An array of settings.
Overrides
BaseAuthenticate::__construct()

authenticate() public ¶

authenticate( CakeRequest $request , CakeResponse $response )

Authenticate a user using basic HTTP auth. Will use the configured User model and attempt a login using basic HTTP auth.

Parameters
CakeRequest $request
The request to authenticate with.
CakeResponse $response
The response to add headers to.
Returns
mixed
Either false on failure, or an array of user data on success.

getUser() public ¶

getUser( CakeRequest $request )

Get a user based on information in the request. Used by cookie-less auth for stateless clients.

Parameters
CakeRequest $request
Request object.
Returns
mixed
Either false or an array of user information
Overrides
BaseAuthenticate::getUser()

loginHeaders() public ¶

loginHeaders( )

Generate the login headers

Returns
string
Headers for logging in.

Methods inherited from BaseAuthenticate

_findUser() protected ¶

_findUser( string $username , string $password )

Find a user record using the standard options.

Parameters
string $username
The username/identifier.
string $password
The unhashed password.
Returns
Mixed
Either false on failure, or an array of user data.

_password() protected ¶

_password( string $password )

Hash the plain text password so that it matches the hashed/encrypted password in the datasource.

Parameters
string $password
The plain text password.
Returns
string
The hashed form of the password.

logout() public ¶

logout( array $user )

Allows you to hook into AuthComponent::logout(), and implement specialized logout behavior.

All attached authentication objects will have this method called when a user logs out.

Parameters
array $user
The user about to be logged out.

Properties detail

$settings ¶

public array

Settings for this object.

  • fields The fields to use to identify a user by.
  • userModel The model name of the User, defaults to User.
  • scope Additional conditions to use when looking up and authenticating users, i.e. array('User.is_active' => 1).
  • recursive The value of the recursive key passed to find(). Defaults to 0.
  • realm The realm authentication is for. Defaults the server name.
array(
    'fields' => array(
        'username' => 'username',
        'password' => 'password'
    ),
    'userModel' => 'User',
    'scope' => array(),
    'recursive' => 0,
    'realm' => '',
)
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