PHP code example of daou / cakephp-auth0-jwt-auth

1. Go to this page and download the library: Download daou/cakephp-auth0-jwt-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daou / cakephp-auth0-jwt-auth example snippets


// In config/bootstrap.php
Plugin::load('Daou/Auth0JwtAuth');

    // In your controller, for e.g. src/Api/AppController.php
    public function initialize()
    {
        parent::initialize();

        $this->loadComponent('Auth', [
            'storage' => 'Memory',
            'authenticate' => [
                'Daou/Auth0JwtAuth.Auth0' => [
                    'fields' => [
                        'username' => 'auth0id'
                    ]
                    'auth0ClientSecret' => '__CLIENT_SECRET__', // only for HS256
                    'auth0Audience' => '__API_AUDIENCE__',
                    'auth0Domain' => '__DOMAIN__'
                ]
            ],

            'unauthorizedRedirect' => false,
            'loginAction' => false
        ]);
    }