Basic
extends AbstractAuth
in package
HTTP Basic authentication utility.
This class helps you setup basic auth. The process is fairly simple:
- Instantiate the class.
- Call getCredentials (this will return null or a user/pass pair)
- If you didn't get valid credentials, call 'requireLogin'
Tags
Table of Contents
- $realm : string
- Authentication realm.
- $request : RequestInterface
- Request object.
- $response : ResponseInterface
- Response object.
- __construct() : mixed
- Creates the object.
- getCredentials() : array<string|int, mixed>|null
- This method returns a numeric array with a username and password as the only elements.
- getRealm() : string
- Returns the HTTP realm.
- requireLogin() : mixed
- This method sends the needed HTTP header and statuscode (401) to force the user to login.
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 —getCredentials()
This method returns a numeric array with a username and password as the only elements.
public
getCredentials() : array<string|int, mixed>|null
If no credentials were found, this method returns null.
Return values
array<string|int, mixed>|null —getRealm()
Returns the HTTP realm.
public
getRealm() : string
Return values
string —requireLogin()
This method sends the needed HTTP header and statuscode (401) to force the user to login.
public
requireLogin() : mixed