Bearer
extends AbstractAuth
in package
HTTP Bearer authentication utility.
This class helps you setup bearer auth. The process is fairly simple:
- Instantiate the class.
- Call getToken (this will return null or a token as string)
- If you didn't get a valid token, call 'requireLogin'
Tags
Table of Contents
- $realm : string
- Authentication realm.
- $request : RequestInterface
- Request object.
- $response : ResponseInterface
- Response object.
- __construct() : mixed
- Creates the object.
- getRealm() : string
- Returns the HTTP realm.
- getToken() : string|null
- This method returns a string with an access token.
- requireLogin() : mixed
- This method sends the needed HTTP header and statuscode (401) to force authentication.
Properties
$realm
Authentication realm.
protected
string
$realm
$request
Request object.
protected
RequestInterface
$request
$response
Response object.
protected
ResponseInterface
$response
Methods
__construct()
Creates the object.
public
__construct([string $realm = 'SabreTooth' ], RequestInterface $request, ResponseInterface $response) : mixed
Parameters
- $realm : string = 'SabreTooth'
- $request : RequestInterface
- $response : ResponseInterface
Return values
mixed —getRealm()
Returns the HTTP realm.
public
getRealm() : string
Return values
string —getToken()
This method returns a string with an access token.
public
getToken() : string|null
If no token was found, this method returns null.
Return values
string|null —requireLogin()
This method sends the needed HTTP header and statuscode (401) to force authentication.
public
requireLogin() : mixed