Auth
in package
Library for authenticating all requests
Table of Contents
- $accessTokenPrivateKeyPath : string
- $accessTokenPublicKeyPath : string
- $refreshTokenPrivateKeyPath : string
- $refreshTokenPublicKeyPath : string
- authenticateUser() : bool
- Verifies all credentials supplied by a signed in user
- generateAccessToken() : string
- Generate JWT access token
- generateFingerprint() : string
- Generate fingerprint using device information
- generateRefreshToken() : string
- Generate JWT refresh token
- isAccessTokenValid() : bool
- Validates JWT token and regenerates new token if expired
- isFingerprintValid() : bool
- Verifies if generated fingerprint matches users fingerprint
- isUserAgentValid() : bool
- Validates if request is from recognised sender
- getAccessTokenPrivateKey() : mixed
- Loads access token private key used for JWT encoding
- getAccessTokenPublicKey() : string
- Loads access token public key used for decoding
- getJWTExpirationTime() : int
- Generates JWT expiration time (+1hour)
- getRefreshTokenPrivateKey() : mixed
- Loads refresh token private key used for JWT encoding
- getRefreshTokenPublicKey() : string
- Loads refresh token public key used for decoding
- isRefreshTokenValid() : bool
- Verifies if refresh token is valid
Properties
$accessTokenPrivateKeyPath
private
static string
$accessTokenPrivateKeyPath
= __DIR__ . '/keys/access_token_private.pem'
Path of access token private key
$accessTokenPublicKeyPath
private
static string
$accessTokenPublicKeyPath
= __DIR__ . '/keys/access_token_public.pem'
Path of access token public key
$refreshTokenPrivateKeyPath
private
static string
$refreshTokenPrivateKeyPath
= __DIR__ . '/keys/refresh_token_private.pem'
Path of refresh token private key
$refreshTokenPublicKeyPath
private
static string
$refreshTokenPublicKeyPath
= __DIR__ . '/keys/refresh_token_public.pem'
Path of refresh token public key
Methods
authenticateUser()
Verifies all credentials supplied by a signed in user
public
static authenticateUser() : bool
Return values
bool —generateAccessToken()
Generate JWT access token
public
static generateAccessToken(string $username, string $email) : string
Parameters
- $username : string
- $email : string
Return values
string —generateFingerprint()
Generate fingerprint using device information
public
static generateFingerprint() : string
Return values
string —generateRefreshToken()
Generate JWT refresh token
public
static generateRefreshToken(mixed $username, mixed $email) : string
Parameters
- $username : mixed
- $email : mixed
Return values
string —isAccessTokenValid()
Validates JWT token and regenerates new token if expired
public
static isAccessTokenValid() : bool
Return values
bool —isFingerprintValid()
Verifies if generated fingerprint matches users fingerprint
public
static isFingerprintValid(mixed $fingerprint) : bool
Parameters
- $fingerprint : mixed
Return values
bool —isUserAgentValid()
Validates if request is from recognised sender
public
static isUserAgentValid() : bool
Return values
bool —getAccessTokenPrivateKey()
Loads access token private key used for JWT encoding
private
static getAccessTokenPrivateKey() : mixed
Return values
mixed —getAccessTokenPublicKey()
Loads access token public key used for decoding
private
static getAccessTokenPublicKey() : string
Return values
string —getJWTExpirationTime()
Generates JWT expiration time (+1hour)
private
static getJWTExpirationTime(int $currentTime) : int
Parameters
- $currentTime : int
Return values
int —getRefreshTokenPrivateKey()
Loads refresh token private key used for JWT encoding
private
static getRefreshTokenPrivateKey() : mixed
Return values
mixed —getRefreshTokenPublicKey()
Loads refresh token public key used for decoding
private
static getRefreshTokenPublicKey() : string
Return values
string —isRefreshTokenValid()
Verifies if refresh token is valid
private
isRefreshTokenValid() : bool