tvdijen/saml2

SimpleSAMLphp 的 SAML2 PHP 库

维护者

详细信息

github.com/tvdijen/saml2

源代码


README

Build Status Coverage Status

SAML2 相关功能的 PHP 库。从 SimpleSAMLphp 提取,由 OpenConext 使用。该库最初是 UNINETTSURFnet 之间的合作项目,但任何人都可以参与贡献。

使用前请阅读

除非您非常熟悉 SAML2 规范,否则请不要使用此库。

如果您不熟悉 SAML2 规范,只是想使用 SAML2 连接您的应用程序,您可能应该使用 SimpleSAMLphp

请注意,HTTP Artifact Binding 和 SOAP 客户端仅在 SimpleSAMLphp 中工作。

选择哪个版本?

最新发布的版本(4.x 范围)是 推荐版本3.x 分支 是我们的 LTS 分支,只要 SimpleSAMLphp 没有迁移到 4.x 分支,就会继续支持。

所有其他分支(2.x 及更早版本)不再受支持,将不会收到任何维护或(安全)修复。请勿使用这些版本。

我们遵循 语义版本化。如果您从旧版本升级,请务必检查 UPGRADING.md 文件。在这里,您将找到关于如何处理版本之间的 BC 破坏性更改的说明。

用法

  • 使用 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