oclockdev / keycloak-jwt-guard
A library to decode JWT provided by Keycloak
Installs: 300
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/oclockdev/keycloak-jwt-guard
Requires
- firebase/php-jwt: ^6.4
- guzzlehttp/guzzle: ^7.5
This package is not auto-updated.
Last update: 2025-12-31 20:03:01 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();