ym-careers / saml2
SimpleSAMLphp 的 SAML2 PHP 库
v2.0.0
2022-08-26 08:12 UTC
Requires
- php: >=5.4
- ext-dom: *
- ext-openssl: *
- ext-zlib: *
- psr/log: ~1.0
- robrichards/xmlseclibs: ^3.0
Requires (Dev)
- mockery/mockery: ~0.9
- phpmd/phpmd: ~1.5
- phpunit/phpunit: ~4
- sebastian/phpcpd: ~1.4
- sensiolabs/security-checker: ~1.1
- squizlabs/php_codesniffer: ~1.4
This package is auto-updated.
Last update: 2024-09-26 12:39:43 UTC
README
A PHP library for SAML2 related functionality. Extracted from SimpleSAMLphp, used by OpenConext. This library started as a collaboration between UNINETT and SURFnet but everyone is invited to contribute.
在使用之前
除非您非常熟悉 SAML2 规范,否则请不要使用此库。
如果您不熟悉 SAML2 规范,只想使用 SAML2 连接您的应用程序,您可能应该使用 SimpleSAMLphp。
注意,HTTP Artifact 绑定和 SOAP 客户端在 SimpleSAMLphp 之外不工作。
选择哪个版本?
最新发布的版本(3.x
范围)是 唯一支持的版本。
所有其他分支(2.x
及更早版本)不再受支持,也不会收到任何维护或(安全)修复。请勿使用这些版本。
用法
- 使用 Composer 安装,在您的项目中运行以下命令
composer require simplesamlphp/saml2:^3.0
-
通过扩展和实现
SAML2\Compat\AbstractContainer
来提供所需的外部依赖项,然后将它注入到 ContainerSingleton 中(请参见下面的示例)。 -
请确保您已经阅读了下面的安全部分.
-
随意使用。示例
// Use Composers autoloading require 'vendor/autoload.php'; // Implement the Container interface (out of scope for example) require 'container.php'; SAML2\Compat\ContainerSingleton::setContainer($container); // Set up an AuthnRequest $request = new SAML2\AuthnRequest(); $request->setId($container->generateId()); $request->setIssuer('https://sp.example.edu'); $request->setDestination('https://idp.example.edu'); // Send it off using the HTTP-Redirect binding $binding = new SAML2\HTTPRedirect(); $binding->send($request);
安全性
- 如果您需要创建 DOMDocument 实例,请使用
SAML2\DOMDocumentFactory
从字符串(SAML2\DOMDocumentFactory::fromString($theXmlAsString)
)、文件(SAML2\DOMDocumentFactory::fromFile($pathToTheFile)
)或新实例(SAML2\DOMDocumentFactory::create()
)创建 DOMDocuments。这样做是为了保护自己免受 XXE 处理漏洞 以及 XML 实体扩展 攻击。
许可协议
此库采用 LGPL 许可协议版本 2.1 许可。有关更多详细信息,请参阅 LICENSE。