yangze / oauth2-keycloak
Keycloak OAuth 2.0 客户端提供者的包装器
v2.0.9
2021-08-16 03:55 UTC
Requires
- php: ^7.3|^8.0
- firebase/php-jwt: ^4.0
- guzzlehttp/guzzle: ^6.0
- league/oauth2-client: ^2.0 <2.3.0
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~2.0
- dev-main
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- dev-master / 1.0.x-dev
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dev_1.0.24
- dev-dev_1.0.23
- dev-dev_1.0.22
- dev-dev_1.0.21
- dev-dev_ci_cache
- dev-dev_1.0.17
- dev-dev_0515_auth
This package is auto-updated.
Last update: 2024-09-16 10:57:09 UTC
README
Keycloak OAuth 2.0 客户端提供者的包装器,支持认证和授权。
安装
要安装,请使用 composer
composer require yangze/oauth2-keycloak
初始化
$passport = Passport::init([ 'authServerUrl' => 'http://127.0.0.1:8080/auth', 'realm' => 'xxxx', 'clientId' => 'backend', 'clientSecret' => 'xxxxx', 'redirectUri' => 'http://127.0.0.1:8003/auto', 'periodNoCheck' => 3600, 'periodCheck' => 180, ]);
认证
登录
$user = $passport->checkLogin(); $user->getAttr('username'); $user->toArray();
登出
$passport->logout();
其他方法
$passport->getAccessToken(); // can save in client $passport->getToken(); // secret $passport->getAuthorizationUrl(); $passport->getLogoutUrl();
授权
$user = $passport->checkAuth(); // permission $user->can($resource, $scope); $user->cannot($resource, $scope); // list $user->getClients(); $user->getPermissions(); // role $user->getRoles(); $user->hasRole($role); $user->inRoles($roleList);