programster/saml
Composer 安装命令:
composer require programster/saml
包简介
A library to help with interfacing with a SAML SSO. This does so by wrapping around the onelogin/php-saml package.
README 文档
README
A package to help with integrating with a SAML SSO.
Example Usage
All of the examples require first creating the SAML "client" which has all of the settings. One must create it like so:
$spConfig = new Programster\Saml\ServiceProviderConfig( entityId: APP_SERVICE_PROVIDER_IDENTITY, name: APP_SERVICE_PROVIDER_NAME, description: "A test service provider", loginHandlerUrl: APP_URL . "/auth/saml-login-handler", logoutHandlerUrl: APP_URL . "/auth/saml-logout-handler", publicCert: file_get_contents(SERVICE_PROVIDER_CERT_PATH), privateKey: file_get_contents(SERVICE_PROVIDER_PRIVATE_KEY_PATH) ); $idpConfig = new \Programster\Saml\IdentityProviderConfig( entityId: IDENTITY_PROVIDER_IDENTITY_URI, authUrl: IDENTITY_PROVIDER_AUTH_URL, logoutUrl: IDENTITY_PROVIDER_LOGOUT_URL, publicSigningCertificates: [file_get_contents(IDENTITY_PROVIDER_PUBLIC_SIGNING_CERT)], ); $samlConfig = new \Programster\Saml\SamlConfig($spConfig, $idpConfig); $samlClient = new \Programster\Saml\SamlClient($samlConfig);
I know that seems a bit long-winded, but the client requires a lot of settings to be configured, and I prefer this over expecting the developer to just pass in an array of key/value pairs and expecting them to know what keys they need to set etc.
Once you have the SAML client, you can use it for handling all the requests/responses like so:
Send the user with a signed SAML request to the SSO to log in and then get redirected back to our site with their information:
$returnToURL = "https://localhost/saml-login-handler"; $samlClient->handleUserLoginRequest($returnToURL);
Then use the client to handle the response from the SSO logging in and redirecting back to our site with the user's details:
$response = $samlClient->handleSamlLoginResponse(); $userAttributes = $response->getUserAttributes(); $userEmail = $userAttributes['email'][0];
Use the client to send a logout request to the SSO:
$returnToUrl = 'http://my.domain.com/auth/saml-logout-handler'; $samlClient->handleUserLogoutRequest($returnToUrl);
Handle the response from the SSO for that logout request:
$ssoLoggedOutUrl = $samlClient->handleSamlLogoutResponse();
programster/saml 适用场景与选型建议
programster/saml 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 212 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「SSO」 「saml」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 programster/saml 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 programster/saml 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 programster/saml 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel package for Saml2 integration as a SP (service provider) for multiple IdPs, based on OneLogin toolkit which is much more lightweight than simplesamlphp.
Zend\Authentication SAML adapter. Uses existing simpleSAMLphp install.
Light SAML 2.0 PHP library
SSO Authentication for your TYPO3 Frontend
Simple Single Sign-On
Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client
统计信息
- 总下载量: 212
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-18