Auth0 PHP - manually authenticating JWT idTokens
2 days ago
- Auth0 documentation is poorly documented despite being a large project with many customers.
- For JWT authentication with Auth0, only the idToken is needed, which consists of Base64-encoded JSON header, body, and signature.
- Using the Auth0 PHP library with Symfony, the token can be decoded by creating an Auth0 instance with domain, clientId, clientSecret, and a dummy cookieSecret, then calling decode with the token and tokenType set to TYPE_ID_TOKEN.
- After successful decoding, user details can be accessed by converting the decoded token to an array (e.g., $claims = $decoded->toArray()) and accessing properties like nickname or sub.
- The article criticizes the lack of official documentation for this process, relying on source code reading.