quartsoft/samlsso

该包的最新版本(dev-master)没有提供许可证信息。

Yii 2 的 SAML SSO 扩展

dev-master 2017-02-27 10:33 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:51:14 UTC


README

将 Yii 2 应用程序连接到 Saml 身份提供者以实现单点登录

安装

安装此扩展的首选方式是通过 composer

稍后运行

php composer.phar require --prefer-dist quartsoft/samlsso "dev-master"

或添加

"quartsoft/samlsso": "dev-master"

到您的 composer.json 文件的 require 部分。

配置

config/web.php 中将 quartsoft\samlsso\Saml 注册到组件中。

'components' => [
    'samlsso' => [
        'class' => 'quartsoft\samlsso\Samlsso',
        'configFile' => '@common/config/samlcofig.php' // OneLogin_Saml config file (Optional)
    ]
]

此组件需要一个存储在 PHP 文件中的 OneLogin_Saml 配置。默认的 configFile 值为 @common/config/samlcofig.php,因此请确保在之前创建此文件。此文件必须返回 OneLogin_Saml 配置。有关示例配置,请参阅此 链接

<?php
return [
    'sp' => [
        'entityId' => '',
        'assertionConsumerService' => [
            'url' => '',
            'binding' => '',
        ],
        'singleLogoutService' => [
            'url' => '',
            'binding' => '',
        ]
    ],

    'idp' => [
        'entityId' => '',
        'singleSignOnService' => [
            'url' => '',
            'binding' => '',
        ],
        'singleLogoutService' => [
            'url' => '',
            'binding' => '',
        ],
        'x509cert' => '',
    ],
];

您可以在以下位置找到示例配置文件:这里

使用方法

使用 actionLogin 的控制器必须继承自 SamlController。并在方法 actions() 中添加 array_merge。

use quartsoft\samlsso\controllers\SamlController;

class SiteController extends SamlController
{

...

    public function actions()
    {
        $actions = parent::actions();

        $currentActions = [
            'your action' => [
                'class' => 'your class',
            ],
            ...
        ];

        return array_merge($actions, $currentActions);

    }

...

}

最后

有关更多信息,请参阅 onelogin/php-saml 库。