oclockdev / keycloak-jwt-guard
A library to decode JWT provided by Keycloak
v1.1.1
2023-04-11 09:09 UTC
Requires
- firebase/php-jwt: ^6.4
- guzzlehttp/guzzle: ^7.5
This package is not auto-updated.
Last update: 2025-07-02 17:50:45 UTC
README
A library to decode JWT provided by Keycloak
How to use?
<?php use Oclockdev\KeycloakJwtGuard\Guard\KeycloakGuard; require_once "./vendor/autoload.php"; // Get the bearer token from the request $accessToken = $_SERVER['HTTP_AUTHORIZATION']; // Create a new instance of KeycloakGuard with Keycloak server info $keycloakGuard = new KeycloakGuard([ "serverUrl" => "https://localhost:8080", "realm" => "master", "accessToken" => $accessToken ]); // Authenticate with the access token and return the JWT payload $payload = $keycloakGuard->authenticate(); // Call the userinfo keycloak endpoint with the access token $userinfo = $keycloakGuard->getOwnerRessource();