KeyAuthEndpoint
extends EndpointBase
in package
Allows an endpoint to require an API key to be present (and valid) in the request.
Tags
Table of Contents
Constants
- AUTH_TYPE_API_KEY = 'API Key'
- AUTH_TYPE_CUSTOM = 'Custom'
- AUTH_TYPE_NONE = 'None'
Properties
- $_description : string
- $_method : string
- $_module : string
- $_route : string
Methods
- customParams() : array<string|int, mixed>
- Allow auth methods to add custom params to endpoint.
- getAuthType() : string
- Get the authentication type of this Endpoint.
- getDescription() : string
- Get description of this Endpoint.
- getMethod() : string
- Get method of this Endpoint (either `POST` or `GET`).
- getModule() : string
- Get name of module of this Endpoint.
- getRoute() : string
- Get route of this Endpoint.
- isAuthorised() : bool
- Determine if the passed API key (in Authorization header) is valid.
- validateKey() : bool
- Validate provided API key to make sure it matches.
Constants
AUTH_TYPE_API_KEY
public
mixed
AUTH_TYPE_API_KEY
= 'API Key'
AUTH_TYPE_CUSTOM
public
mixed
AUTH_TYPE_CUSTOM
= 'Custom'
AUTH_TYPE_NONE
public
mixed
AUTH_TYPE_NONE
= 'None'
Properties
$_description
protected
string
$_description
$_method
protected
string
$_method
$_module
protected
string
$_module
$_route
protected
string
$_route
Methods
customParams()
Allow auth methods to add custom params to endpoint.
public
customParams() : array<string|int, mixed>
Return values
array<string|int, mixed> —Custom endpoint params
getAuthType()
Get the authentication type of this Endpoint.
public
final getAuthType() : string
Determined by seeing what class it extends. Used to display in the API Endpoints StaffCP page.
Return values
string —The auth type.
getDescription()
Get description of this Endpoint.
public
final getDescription() : string
Return values
string —Endpoint's description.
getMethod()
Get method of this Endpoint (either `POST` or `GET`).
public
final getMethod() : string
Return values
string —Endpoint's method.
getModule()
Get name of module of this Endpoint.
public
final getModule() : string
Return values
string —Endpoint's modules name.
getRoute()
Get route of this Endpoint.
public
final getRoute() : string
Return values
string —Endpoint's route.
isAuthorised()
Determine if the passed API key (in Authorization header) is valid.
public
final isAuthorised(Nameless2API $api) : bool
Parameters
- $api : Nameless2API
-
Instance of the Nameless2API class
Return values
bool —Whether the API key is valid
validateKey()
Validate provided API key to make sure it matches.
private
validateKey(string $api_key) : bool
Parameters
- $api_key : string
-
API key to check.
Return values
bool —Whether it matches or not.