https://github.com/xrian/php-keycloak-demo
PHP 解析 keycloak Access Token 的 Demo
https://github.com/xrian/php-keycloak-demo
jwt keycloak php
Last synced: about 1 year ago
JSON representation
PHP 解析 keycloak Access Token 的 Demo
- Host: GitHub
- URL: https://github.com/xrian/php-keycloak-demo
- Owner: xrian
- Created: 2020-08-28T07:03:06.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-28T07:04:45.000Z (almost 6 years ago)
- Last Synced: 2025-02-16T18:43:44.123Z (over 1 year ago)
- Topics: jwt, keycloak, php
- Language: PHP
- Homepage:
- Size: 396 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
找了下,git 上面没有PHP整合 keycloak 的例子,就写了一个
# 使用方法
更新 test.php 中的 $public_key_str 和 $config_json


然后执行 test.php 中的测试用例,就可以看到解析 jwt 后的结果
## 获取 token 的地址
```shell script
curl --location --request POST '{{host}/auth/realms/{{realm}}/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username={{username}}' \
--data-urlencode 'password={{password}}' \
--data-urlencode 'client_id={{client}}' \
--data-urlencode 'grant_type=password'
```
参考资料:
https://stackoverflow.com/questions/62631223/keycloak-validating-access-token-using-php