Firesphere\GraphQLJWT\Authentication\JWTAuthenticator
Synopsis
class JWTAuthenticator
extends MemberAuthenticator
{
- // constants
- const JWT_SIGNER_KEY = 'JWT_SIGNER_KEY';
- const JWT_KEY_PASSWORD = 'JWT_KEY_PASSWORD';
- const JWT_PUBLIC_KEY = 'JWT_PUBLIC_KEY';
- const RSA = 'RSA';
- const RSA_PASSWORD = 'RSA_PASSWORD';
- const HMAC = 'HMAC';
- // members
- private static bool $anonymous_allowed = false;
- private static integer $nbf_time = 0;
- private static integer $nbf_expiration = 3600;
- private static integer $nbf_refresh_expiration = 604800;
- // methods
- protected string getKeyType()
- protected Signer getSigner()
- protected Key getPrivateKey()
- protected Key getPublicKey()
- private Key makeKey()
- public int supportedServices()
- public Member|null authenticate()
- public Token generateToken()
- public array|null validateToken()
- protected Token|null parseToken()
- protected bool validateParsedToken()
- protected bool canTokenBeRenewed()
- protected string|null resolvePath()
- protected string|null getEnv()
- // Inherited methods from MemberTokenGenerator
- public string getErrorMessage()
- protected array generateResponse()
Hierarchy
Extends
- SilverStripe\Security\MemberAuthenticator\MemberAuthenticator
Uses
- SilverStripe\Core\Injector\Injectable
- SilverStripe\Core\Config\Configurable
- Firesphere\GraphQLJWT\Helpers\MemberTokenGenerator
Constants
Name | Value |
---|---|
JWT_SIGNER_KEY | 'JWT_SIGNER_KEY' |
JWT_KEY_PASSWORD | 'JWT_KEY_PASSWORD' |
JWT_PUBLIC_KEY | 'JWT_PUBLIC_KEY' |
RSA | 'RSA' |
RSA_PASSWORD | 'RSA_PASSWORD' |
HMAC | 'HMAC' |
Members
private
- $anonymous_allowed
—
Firesphere\GraphQLJWT\Authentication\bool
Set to true to allow anonymous JWT tokens (no member record / email / password) - $nbf_expiration
—
int
Expires after 1 hour - $nbf_refresh_expiration
—
int
Token can be refreshed within 7 days - $nbf_time — int
Methods
private
- makeKey() — Construct a new key from the named config variable
protected
- canTokenBeRenewed() — Check if the given token can be renewed
- getEnv() — Get an environment value. If $default is not set and the environment isn't set either this will error.
- getKeyType() — Keys are one of: - public / private RSA pair files - public / private RSA pair files, password protected private key - private HMAC string
- getPrivateKey() — Get private key used to generate JWT tokens
- getPublicKey() — Get public key used to validate JWT tokens
- getSigner()
- parseToken() — Parse a string into a token
- resolvePath() — Return an absolute path from a relative one If the path doesn't exist, returns null
- validateParsedToken() — Determine if the given token is current, given the context of the current request
public
- authenticate()
- generateToken() — Generate a new JWT token for a given request, and optional (if anonymous_allowed) user
- supportedServices() — JWT is stateless, therefore, we don't support anything but login
- validateToken()
Inherited from Firesphere\GraphQLJWT\Helpers\MemberTokenGenerator
protected
- generateResponse() — Generate MemberToken response
public
- getErrorMessage() — Humanise error message based on status code