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.7 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.7
      • 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
    • Command
    • 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

    Load AuthComponent in your controller's initialize() and add 'Basic' in 'authenticate' key

     $this->loadComponent('Auth', [
         'authenticate' => ['Basic']
         'storage' => 'Memory',
         'unauthorizedRedirect' => false,
     ]);

    You should set storage to Memory to prevent CakePHP from sending a session cookie to the client.

    You should set unauthorizedRedirect to false. This causes AuthComponent to throw a ForbiddenException exception instead of redirecting to another page.

    Since HTTP Basic Authentication is stateless you don't need call setUser() 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.

  • 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

    Load AuthComponent in your controller's initialize() and add 'Digest' in 'authenticate' key

     $this->loadComponent('Auth', [
         'authenticate' => ['Digest'],
         'storage' => 'Memory',
         'unauthorizedRedirect' => false,
     ]);

    You should set storage to Memory to prevent CakePHP from sending a session cookie to the client.

    You should set unauthorizedRedirect to false. This causes AuthComponent to throw a ForbiddenException exception instead of redirecting to another page.

    Since HTTP Digest Authentication is stateless you don't need call setUser() 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.

    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

    Form authentication adapter for AuthComponent.

    Allows you to authenticate users based on form POST data. Usually, this is a login form that users enter information into.

    Using Form auth

    Load AuthComponent in your controller's initialize() and add 'Form' in 'authenticate' key

    $this->loadComponent('Auth', [
        'authenticate' => [
            'Form' => [
                'fields' => ['username' => 'email', 'password' => 'passwd'],
                'finder' => 'auth',
            ]
        ]
    ]);

    When configuring FormAuthenticate you can pass in config to which fields, model and finder are used. See BaseAuthenticate::$_defaultConfig 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