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.
checkRS512 Decides if the provided JWT token is signed with the RS512 Algorithm.
convertRSAtoJWK
getAlgorithm
getApplicationId
getAuthentication
getCertificate Writes the certificate and ssl keys to disk, returns the filenames.
getHmacToken
getJWK
getJwtPayload
getJwtToken Create a JWT token from Component settings.
getTokenFromUrl
removeFiles Removes certificates and private keys from disk if they are not necessary anymore.
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::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::convertRSAtoJWK

Description

 convertRSAtoJWK (void)

Parameters

This function has no parameters.

Return Values

void


AuthenticationService::getAlgorithm

Description

 getAlgorithm (void)

Parameters

This function has no parameters.

Return Values

void


AuthenticationService::getApplicationId

Description

 getApplicationId (void)

Parameters

This function has no parameters.

Return Values

void


AuthenticationService::getAuthentication

Description

 getAuthentication (void)

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

 getHmacToken (void)

Parameters

This function has no parameters.

Return Values

void


AuthenticationService::getJWK

Description

 getJWK (void)

Parameters

This function has no parameters.

Return Values

void


AuthenticationService::getJwtPayload

Description

 getJwtPayload (void)

Parameters

This function has no parameters.

Return Values

void


AuthenticationService::getJwtToken

Description

public getJwtToken (array $component, string $)

Create a JWT token from Component settings.

Parameters

  • (array) $component : The code of the component
  • (string) $ : The JWT token

Return Values

void


AuthenticationService::getTokenFromUrl

Description

 getTokenFromUrl (void)

Parameters

This function has no parameters.

Return Values

void


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::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