felipe.devops/laravel-keycloak-admin
Composer 安装命令:
composer require felipe.devops/laravel-keycloak-admin
包简介
Keycloak Admin Rest API for Laravel/Lumen
README 文档
README
This is a forked repository from https://github.com/Mnikoei/laravel-keycloak-admin
Original work credited to Mnikoei.
Alternative
Keycloak Admin library made by Scito. https://gitlab.com/scito-performance/keycloak-admin
Supports
Installation
composer require haizad/laravel-keycloak-admin
Copy the package config to your local config with the publish command:
Laravel only
php artisan vendor:publish --provider="LaravelKeycloakAdmin\KeycloakAdminServiceProvider"
Lumen only
Create a config folder in the root directory.
Copy keycloakAdmin.php from vendor/haizad/laravel-keycloak-admin/src/Config/, and paste into config folder.
Register the provider in your boostrap app file bootstrap/app.php
Add the following line at that files. Please note that
$app->configure('keycloakAdmin'); should be placed below
$app->register(\LaravelKeycloakAdmin\KeycloakAdminServiceProvider::class);.
//"Register Service Providers" section $app->register(\LaravelKeycloakAdmin\KeycloakAdminServiceProvider::class); $app->configure('keycloakAdmin'); $app->router->group([ 'namespace' => 'App\Http\Controllers', ], function ($router) { require __DIR__.'/../routes/web.php'; }); return $app;
For facades, uncomment $app->withFacades(); in your boostrap app file bootstrap/app.php
Environment Setup
Add these environment variables to your .env :
KEYCLOAK_BASE_URL=http://keycloak-domain.example/auth
KEYCLOAK_REALM=
KEYCLOAK_REALM_PUBLIC_KEY= # realm settings -> keys
KEYCLOAK_CLIENT_ID=
KEYCLOAK_CLIENT_SECRET= # clients -> your_client -> credentials
KEYCLOAK_ADMIN_BASE_URL=${KEYCLOAK_BASE_URL}/admin/realms/${KEYCLOAK_REALM}
Enable realm managment
Go to clients -> your_client -> Service Account then select realm-managment
from Client Roles list and assign realm-admin to client.
Available methods :
Package has provided services as below:
- user
- role
- client
- clientRole
- addon
Available functions:
- Create User
- Get All User
- Query User
All API's are declared in config\keycloakAdmin.php
Usages
Include the KeycloakAdmin inside your Laravel controller/API route
use LaravelKeycloakAdmin\Facades\KeycloakAdmin;
Example:
KeycloakAdmin::serviceName()->apiName($parameters) //Create User Sample //Refer https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_userrepresentation KeycloakAdmin::user()->create([ 'body' => [ 'username' => 'foo', 'enabled' => true, 'emailVerified' => false, 'email' => 'foo@email.com', 'credentials' => [[ 'type' => 'password', 'value' => 'foobar', 'temporary' => false ]] ] ]); //Query User Sample //Refer Query parameter on GET /{realm}/users https://www.keycloak.org/docs-api/11.0/rest-api/index.html KeycloakAdmin::user()->find([ 'query' => [ 'email' => 'foobar@example.com' ] ]); //Get All User Sample KeycloakAdmin::user()->all();
Additional Methods
Logout User session by user Id
KeycloakAdmin::addon()->logoutById([
'id' => 'user_id'
])
Set Expiry Access Token
KeycloakAdmin::addon()->setAccessTokenExpiry([
'body' => [
'accessTokenLifespan' => 60
]
])
To do list
- Lumen Support
- Test LDAP Connection
- Import users from LDAP
All other api calls are same as examples just needs to provide required parameters as described in https://www.keycloak.org/docs-api/11.0/rest-api/index.html
felipe.devops/laravel-keycloak-admin 适用场景与选型建议
felipe.devops/laravel-keycloak-admin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 felipe.devops/laravel-keycloak-admin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 felipe.devops/laravel-keycloak-admin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-29