Let's have a look at the built-in decoders!

# Basic

This decoder will handle BasicAuth using the Authorization header and return a EonX\EasyApiToken\Interfaces\Tokens\BasicAuthEasyApiTokenInterface instance. This interface allows you to retrieve the username and password provided on the request.


# User ApiKey

This decoder will handle an ApiKey passed as the BasicAuth username in the Authorization header and return a EonX\EasyApiToken\Interfaces\Tokens\ApiKeyEasyApiTokenInterface instance. This interface allows you to retrieve the ApiKey given on the request.

Required otherwise it breaks the warning format below

WARNING

If a password is given as part of the BasicAuth this decoder will not consider it as an ApiKey.


# JWT Header

This decoder will handle Bearer token using the Authorization header and return a EonX\EasyApiToken\Interfaces\Tokens\JwtEasyApiTokenInterface instance. This interface allows you to retrieve any claim on the JWT, retrieve claims as array (useful for hash) and check the presence of a claim.


# JWT Param

This decoder will handle a JWT as query parameter, it will return the same instance as JWT Header.


# JWT Drivers

When using the JWT decoders, you will have to configure the underlying driver you want to use or even create your own. By default, this package comes with 3 built-in drivers:

  • Amazon Cognito: Allows you to decode JWT from Amazon Cognito (opens new window). The following dependencies are required and need to be installed:
    • composer require firebase/php-jwt:^5.0
    • composer require phpseclib/phpseclib:^3.0
  • Auth0: Allows you to decode JWT from Auth0 (opens new window). The following dependencies are required and need to be installed:
    • composer require auth0/auth0-php:^5.4 (or the ^7.6 version)
  • Firebase: Allows you to decode JWT using the Firebase PHP package (opens new window). The following dependencies are required and need to be installed:
    • composer require firebase/php-jwt:^5.0