oclockdev / keycloak-jwt-guard
Keycloak提供的JWT解码库
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: 2024-09-25 13:57:03 UTC
README
Keycloak提供的JWT解码库
如何使用?
<?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://: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();