BEdita API doc | 4-cactus
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Download

Namespaces

  • BEdita
    • API
      • Auth
      • Controller
        • Admin
        • Component
        • Model
      • Error
      • Event
      • Exception
      • Middleware
      • Model
        • Action
      • Network
        • Exception
      • Shell
      • TestSuite
      • Utility
    • Core
      • Configure
        • Engine
      • Database
        • Type
      • Exception
      • Filesystem
        • Adapter
        • Exception
        • Thumbnail
      • I18n
      • Job
        • Service
      • Mailer
        • Preview
        • Transport
      • Model
        • Action
        • Behavior
        • Entity
        • Table
        • Validation
      • ORM
        • Inheritance
        • Locator
        • Rule
      • Shell
        • Task
      • State
      • TestSuite
        • Fixture
      • Utility

Classes

  • AnonymousAuthenticate
  • JwtAuthenticate
  • OTPAuthenticate
  • UuidAuthenticate

Class JwtAuthenticate

An authentication adapter for authenticating using JSON Web Tokens.

$this->Auth->config('authenticate', [
     'BEdita/Auth.Jwt' => [
         'parameter' => 'token',
         'userModel' => 'Users',
         'fields' => [
             'username' => 'id',
         ],
     ],
 ]);
Cake\Auth\BaseAuthenticate
Extended by BEdita\API\Auth\JwtAuthenticate
Namespace: BEdita\API\Auth
See: http://jwt.io
See: http://tools.ietf.org/html/draft-ietf-oauth-json-web-token
Since: 4.0.0
Located at API/src/Auth/JwtAuthenticate.php

Methods summary

public array|false
# authenticate( Cake\Http\ServerRequest $request, Cake\Http\Response $response )

Get user record based on info available in JWT.

Get user record based on info available in JWT.

Parameters

$request
The request object.
$response
Response object.

Returns

array|false
User record array or false on failure.
public array|false
# getUser( Cake\Http\ServerRequest $request )

Get user record based on info available in JWT.

Get user record based on info available in JWT.

Parameters

$request
Request object.

Returns

array|false
User record array, false on failure.
public object|false
# getPayload( Cake\Http\ServerRequest $request )

Get payload data.

Get payload data.

Parameters

$request
Request instance or null

Returns

object|false
Payload object on success, false on failure.

Throws

Exception
Throws an exception if the token could not be decoded and debug is active.
public string|null
# getToken( Cake\Http\ServerRequest $request )

Get token from header or query string.

Get token from header or query string.

Parameters

$request
Request object.

Returns

string|null
Token string if found else null.
protected array|false
# decode( string $token, Cake\Http\ServerRequest $request )

Decode JWT token.

Decode JWT token.

Parameters

$token
JWT token to decode.
$request
Request object.

Returns

array|false
The token's payload as a PHP object, false on failure.

Throws

Exception
Throws an exception if the token could not be decoded and debug is active.
public
# unauthenticated( Cake\Http\ServerRequest $request, Cake\Http\Response $response )

Handles an unauthenticated access attempt.

Handles an unauthenticated access attempt.

Parameters

$request
A request object.
$response
A response object.

Throws

Cake\Http\Exception\UnauthorizedException
Throws an exception.

Properties summary

protected array $_defaultConfig

Default config for this object.

Default config for this object.

  • header The header where the token is stored. Defaults to 'Authorization'.
  • headerPrefix The prefix to the token in header. Defaults to 'Bearer'.
  • queryParam The query parameter where the token is passed as a fallback. Defaults to 'token'.
  • allowedAlgorithms List of supported verification algorithms. Defaults to ['HS256']. See API of JWT::decode() for more info.
  • fields The fields to use to identify a user by.
  • userModel The alias for users table, defaults to Users.
  • finder The finder method to use to fetch user record. Defaults to 'all'. You can set finder name as string or an array where key is finder name and value is an array passed to Table::find() options. E.g. ['finderName' => ['some_finder_option' => 'some_value']]
  • passwordHasher Password hasher class. Can be a string specifying class name or an array containing className key, any other keys will be passed as config to the class. Defaults to 'Default'.
  • Options scope and contain have been deprecated since 3.1. Use custom finder instead to modify the query to fetch user record.
# [ 'header' => 'Authorization', 'headerPrefix' => 'Bearer', 'queryParam' => 'token', 'allowedAlgorithms' => [ 'HS256', 'HS512', ], 'fields' => [ 'username' => 'id', 'password' => null, ], 'userModel' => 'Users', 'scope' => [], 'finder' => 'login', 'contain' => null, 'passwordHasher' => 'Default', 'queryDatasource' => false, ]
protected string|null $token

Parsed token.

Parsed token.

# null
protected object|null $payload

Payload data.

Payload data.

# null
protected Exception $error

Exception.

Exception.

#
BEdita API doc | 4-cactus API documentation generated by ApiGen