yangze / oauth2-keycloak
A wrapper for the Keycloak OAuth 2.0 Client Provider
Installs: 3 507
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
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-11-16 11:20:53 UTC
README
A wrapper for the Keycloak OAuth 2.0 Client Provider, support Authentication and Authorization.
Installation
To install, use composer:
composer require yangze/oauth2-keycloak
Init
$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, ]);
Authentication
Login
$user = $passport->checkLogin(); $user->getAttr('username'); $user->toArray();
logout
$passport->logout();
Other Methds
$passport->getAccessToken(); // can save in client $passport->getToken(); // secret $passport->getAuthorizationUrl(); $passport->getLogoutUrl();
Authorization
$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);