alma-medical/keycloak-client
Composer 安装命令:
composer require alma-medical/keycloak-client
包简介
A PHP client for Keycloak REST API
README 文档
README
This package provides a PHP wrapper for Keycloak REST API.
Installation
Run this command to integrate the Keycloak REST API client to your existing project:
composer require alma-medical/keycloak-client
How to use it
First of all we need to configure a oauth2 provider for authenticating against Keycloak. For that purpose we use the stevenmaguire/oauth2-keycloak package, a league/oauth2-client Keycloak provider. This is an example of how to do that:
use Stevenmaguire\OAuth2\Client\Provider\Keycloak as KeycloakProvider; $provider = new KeycloakProvider([ 'authServerUrl' => 'https://my-keycloak.com/auth', 'clientId' => 'myClientId', 'clientSecret' => 'myCleintSecret', 'realm' => 'myRealm', ]);
Once we have our provider instance we need to create an API client:
use AlmaMedical\KeycloakClient\Keycloak; $client = new Keycloak($provider);
Now we can call any api method with callMedthod() function:
$response = $client->callMethod('users');
To make easier the parse of the responses, some methods have been implemented:
Get users
This method gets all the users:
use AlmaMedical\KeycloakClient\Method\GetUsers; $getUsers = new GetUsers($client); $users = $getUsers->call();
Get user
This method get a user
use AlmaMedical\KeycloakClient\Method\GetUser; $getUsers = new GetUser($client, 'user_id'); $user = $getUsers->call();
Cache
You can use a Psr\Cache\CacheItemPoolInterface to cache Keycloak tokens. To use it simply set your CacheItemPoolInterface and the client will package will use it:
use Symfony\Component\Cache\Adapter\FilesystemAdapter; $client->setCachePool(new FilesystemAdapter());
Running tests
To run the tests run the following command:
./vendor/bin/phpunit
alma-medical/keycloak-client 适用场景与选型建议
alma-medical/keycloak-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.11k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2019 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「client」 「keycloak」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alma-medical/keycloak-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alma-medical/keycloak-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alma-medical/keycloak-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Auth package against Keycloak for Saml and Openid-Connect
Mock PSR-18 HTTP client
This package supports Keycloak administrator client API, authenticating with username and password or using the security key (client_secret)
Asynchronous MQTT client built on React
🔑 Simple Keycloak Guard for Laravel
统计信息
- 总下载量: 5.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-12-05