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
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.5 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.5
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 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

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Namespace Auth

Namespaces

  • Cake\Auth\Storage

Classes

  • AbstractPasswordHasher

    Abstract password hashing class

  • BaseAuthenticate

    Base Authentication class with common methods and properties.

  • BaseAuthorize

    Abstract base authorization adapter for AuthComponent.

  • 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.

    Using Basic auth

    In your controller's components array, add auth + the required config

     public $components = [
         'Auth' => [
             'authenticate' => ['Basic']
         ]
     ];

    You should also set AuthComponent::$sessionKey = false; in your AppController's beforeFilter() to prevent CakePHP from sending a session cookie to the client.

    Since HTTP Basic Authentication is stateless you don't need a login() action in your controller. The user credentials will be checked on each request. If valid credentials are not provided, required authentication headers will be sent by this authentication provider which triggers the login dialog in the browser/client.

    You may also want to use $this->Auth->unauthorizedRedirect = false;. By default, unauthorized users are redirected to the referrer URL, AuthComponent::$loginAction, or '/'. If unauthorizedRedirect is set to false, a ForbiddenException exception is thrown instead of redirecting.

  • 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 ($this->request->getParam('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.

  • DefaultPasswordHasher

    Default password hashing class.

  • DigestAuthenticate

    Digest Authentication adapter for AuthComponent.

    Provides Digest HTTP authentication support for AuthComponent.

    Using Digest auth

    In your controller's components array, add auth + the required config

     public $components = [
         'Auth' => [
             'authenticate' => ['Digest']
         ]
     ];

    You should also set AuthComponent::$sessionKey = false; in your AppController's beforeFilter() to prevent CakePHP from sending a session cookie to the client.

    Since HTTP Digest Authentication is stateless you don't need a login() action in your controller. The user credentials will be checked on each request. If valid credentials are not provided, required authentication headers will be sent by this authentication provider which triggers the login dialog in the browser/client.

    You may also want to use $this->Auth->unauthorizedRedirect = false;. This causes AuthComponent to throw a ForbiddenException exception instead of redirecting to another page.

    Generating passwords compatible with Digest authentication.

    DigestAuthenticate requires a special password hash that conforms to RFC2617. You can generate this password using DigestAuthenticate::password()

    $digestPass = DigestAuthenticate::password($username, $password, env('SERVER_NAME'));

    If you wish to use digest authentication alongside other authentication methods, it's recommended that you store the digest authentication separately. For example User.digest_pass could be used for a digest password, while User.password would store the password hash for use with other methods like Basic or Form.

  • FallbackPasswordHasher

    A password hasher that can use multiple different hashes where only one is the preferred one. This is useful when trying to migrate an existing database of users from one password type to another.

  • FormAuthenticate

    An authentication adapter for AuthComponent. Provides the ability to authenticate using POST data. Can be used by configuring AuthComponent to use it via the AuthComponent::$authenticate config.

     $this->Auth->authenticate = [
         'Form' => [
             'finder' => ['auth' => ['some_finder_option' => 'some_value']]
         ]
     ]

    When configuring FormAuthenticate you can pass in config to which fields, model and additional conditions are used. See FormAuthenticate::$_config for more information.

  • PasswordHasherFactory

    Builds password hashing objects

  • WeakPasswordHasher

    Password hashing class that use weak hashing algorithms. This class is intended only to be used with legacy databases where passwords have not been migrated to a stronger algorithm yet.

OpenHub
Pingping
Linode
  • 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
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs