CommonGateway\CoreBundle\Service\AuthenticationService
Methods
| Name | Description |
|---|---|
| __construct | |
| checkHS256 | Decides if the provided JWT token is signed with the HS256 Algorithm. |
| checkHeadersAndGetJWK | Checks the algorithm of the JWT token and decides how to generate a JWK from the provided public key. |
| checkRS256 | Decides if the provided JWT token is signed with the HS256 Algorithm. |
| checkRS512 | Decides if the provided JWT token is signed with the RS512 Algorithm. |
| convertRSAKeyToJWK | Converts a string RSA key to a JWK via the filesystem. |
| convertRSAtoJWK | Converts an RSA private key to a JWK. |
| createJwtToken | Creates a JWT token to identify with on the application. |
| getAlgorithm | Determines the algorithm for the JWT token to create from the source. |
| getApplicationId | Gets an application id for a source. |
| getAuthentication | Gets the authentication values through various checks. |
| getCertificate | Writes the certificate and ssl keys to disk, returns the filenames. |
| getHmacToken | Gets a hmac token. |
| getJWK | Gets a JWK for a source based on the algorithm of the source. |
| getJwtPayload | Creates the JWT payload to identify at an external source. |
| getJwtToken | Create a JWT token from Component settings. |
| getTokenFromUrl | Checks from which type of auth we need to fetch a token from. |
| removeFiles | Removes certificates and private keys from disk if they are not necessary anymore. |
| serializeUser | Serializes a user to be used by the token authenticator. |
| verifyJWTToken | Verifies the JWT token and returns the payload if the JWT token is valid. |
AuthenticationService::__construct
Description
__construct (void)
Parameters
This function has no parameters.
Return Values
void
AuthenticationService::checkHS256
Description
public checkHS256 (\JWT $token)
Decides if the provided JWT token is signed with the HS256 Algorithm.
Parameters
(\JWT) $token: The token provided by the user
Return Values
bool
Whether the token is in HS256 or not
AuthenticationService::checkHeadersAndGetJWK
Description
public checkHeadersAndGetJWK (\JWT $token, string $publicKey)
Checks the algorithm of the JWT token and decides how to generate a JWK from the provided public key.
Parameters
(\JWT) $token: The JWT token sent by the user(string) $publicKey: The public key provided by the application
Return Values
\JWK
The resulting JWK for verifying the JWT
AuthenticationService::checkRS256
Description
public checkRS256 (\JWT $token)
Decides if the provided JWT token is signed with the HS256 Algorithm.
Parameters
(\JWT) $token: The token provided by the user
Return Values
bool
Whether the token is in HS256 or not
AuthenticationService::checkRS512
Description
public checkRS512 (\JWT $token)
Decides if the provided JWT token is signed with the RS512 Algorithm.
Parameters
(\JWT) $token: The token provided by the user
Return Values
bool
Whether the token is in HS256 or not
AuthenticationService::convertRSAKeyToJWK
Description
public convertRSAKeyToJWK (string $key)
Converts a string RSA key to a JWK via the filesystem.
Parameters
(string) $key: The key to load
Return Values
\JWK
The resulting Json Web Key
AuthenticationService::convertRSAtoJWK
Description
public convertRSAtoJWK (\Source $source)
Converts an RSA private key to a JWK.
Parameters
(\Source) $source
Return Values
\JWK
The resulting Json Web Key
AuthenticationService::createJwtToken
Description
public createJwtToken (string $key, array $payload)
Creates a JWT token to identify with on the application.
Parameters
(string) $key: The private key to create a JWT token with(array) $payload: The payload to create a JWT token with
Return Values
string
The resulting JWT token
AuthenticationService::getAlgorithm
Description
public getAlgorithm (\Source $source)
Determines the algorithm for the JWT token to create from the source.
Parameters
(\Source) $source: The source to determine the algorithm for
Return Values
string
The algorithm to use
AuthenticationService::getApplicationId
Description
public getApplicationId (\Source $source)
Gets an application id for a source.
Parameters
(\Source) $source: The source to dermine the application id for
Return Values
string
The application ID to use
AuthenticationService::getAuthentication
Description
public getAuthentication (void)
Gets the authentication values through various checks.
Parameters
This function has no parameters.
Return Values
void
AuthenticationService::getCertificate
Description
public getCertificate (array $config)
Writes the certificate and ssl keys to disk, returns the filenames.
Parameters
(array) $config: The configuration as stored in the source
Return Values
array
The overrides on the configuration with filenames instead of certificate contents
AuthenticationService::getHmacToken
Description
public getHmacToken (void)
Gets a hmac token.
Parameters
This function has no parameters.
Return Values
void
AuthenticationService::getJWK
Description
public getJWK (string $algorithm, \Source $source)
Gets a JWK for a source based on the algorithm of the source.
Parameters
(string) $algorithm(\Source) $source
Return Values
\JWK
The resulting Json Web Key
AuthenticationService::getJwtPayload
Description
public getJwtPayload (\Source $source)
Creates the JWT payload to identify at an external source.
Parameters
(\Source) $source: The source to create a payload for
Return Values
string
The JWT payload to use
AuthenticationService::getJwtToken
Description
public getJwtToken (\Source $source)
Create a JWT token from Component settings.
Parameters
(\Source) $source: The source to authenticate to
Return Values
string
The resulting JWT token
AuthenticationService::getTokenFromUrl
Description
public getTokenFromUrl (\Source $source, string $authType)
Checks from which type of auth we need to fetch a token from.
Parameters
(\Source) $source(string) $authType
Return Values
string|null
Fetched JWT token.
AuthenticationService::removeFiles
Description
public removeFiles (array $config)
Removes certificates and private keys from disk if they are not necessary anymore.
Parameters
(array) $config: The configuration with filenames
Return Values
void
AuthenticationService::serializeUser
Description
public serializeUser (\User $user, \SessionInterface $session)
Serializes a user to be used by the token authenticator.
Parameters
(\User) $user: The user to be serialized(\SessionInterface) $session: The session to use
Return Values
array
The serialized user
AuthenticationService::verifyJWTToken
Description
public verifyJWTToken (string $token, string $publicKey)
Verifies the JWT token and returns the payload if the JWT token is valid.
Parameters
(string) $token: The token to verify(string) $publicKey: The public key to verify the token to
Return Values
array
The payload of the token
Throws Exceptions
\HttpException
Thrown when the token cannot be verified