messageagency/ma_sso_sp

此软件包最新版本(1.0)没有可用的许可证信息。

整理所有需求以创建一个作为SP的Drupal网站

安装: 5

依赖: 0

建议者: 0

安全: 0

类型:ma-module

1.0 2020-12-11 21:12 UTC

This package is not auto-updated.

Last update: 2024-09-14 08:11:39 UTC


README

消息代理单点登录服务提供商。

关于身份提供者(IDP)版本,请参阅: https://bitbucket.org/messageagency/ma_sso_idp

目的

此模块旨在运行一些基本检查,以帮助您调试SAML SSO SP设置。其目的不是配置基于Drupal的简单SAML SP,而是提供一些合理的默认值并帮助您安装。因此,对您的IDP和SP的设置假设非常特定。提供了默认配置文件以供参考,您需要对其进行自定义。

使用此模块的快速入门

  • composer require messageagency/ma_sso_sp
  • drush en ma_sso_sp
  • 转到 admin/reports/status 并按照以下步骤解决任何错误。

假设/先决条件

  • 此Drupal网站将有一个默认的IDP,它是另一个Drupal网站
  • 此Drupal网站将仅实现一个SP
  • 安装和配置将由composer管理
  • composer.json 在您的VCS根目录中
  • 您的drupal webroot是 /web
  • 您的simple saml web安装将通过 https://example.com/simplesaml 链接
  • 此模块将安装到 web/modules/message_agency/ma_sso_sp
  • Drupal私有文件目录位于 web/sites/default/files/private
  • 所有内容都通过 https:// 提供服务,尽管自签名证书是可以的。

详细SP设置指南

  1. 需要此模块

         composer require messageagency/ma_sso_sp
    
  2. 创建简单的saml符号链接

    在您的webroot中添加一个指向simple saml www目录的符号链接。

         cd ./web
         ln -s ../vendor/simplesamlphp/simplesamlphp/www simplesaml
    
  3. 创建本地sso目录并复制配置

    创建一个本地sso目录,例如在 $DRUPAL_ROOT/sso 中,并将配置从 ma_sso_sp/sso 复制到其中。

     mkdir sso 
     cp web/modules/message_agency/ma_sso_idp/sso/* sso/ 
    
  4. 编辑 saml20-idp-remote.php 以指向您的IDP

    将所有 www.messageagency.com 实例替换为您的IDP域名。

  5. 编辑 authsources.php 以指向您的IDP

    www.messageagency.com 替换为您的IDP域名。

  6. Composer任务

    将以下规则添加到 composer.json 中,以便composer任务不会破坏您的saml配置。

     "post-install-cmd": [
         "cp sso/config.php ./vendor/simplesamlphp/simplesamlphp/config/config.php",
         "cp sso/authsources.php ./vendor/simplesamlphp/simplesamlphp/config/authsources.php",
         "cp sso/saml20-idp-remote.php ./vendor/simplesamlphp/simplesamlphp/metadata/saml20-sp-remote.php",
     ],
     "post-update-cmd": [
         "cp sso/config.php ./vendor/simplesamlphp/simplesamlphp/config/config.php",
         "cp sso/authsources.php ./vendor/simplesamlphp/simplesamlphp/config/authsources.php",
         "cp sso/saml20-idp-remote.php ./vendor/simplesamlphp/simplesamlphp/metadata/saml20-idp-hosted.php"
     ],
    
  7. 需要此模块(再次)或重新安装以部署配置

    要部署上一步骤中的配置,需要此模块或运行 composer install

         composer require messageagency/ma_sso_sp
    
  8. 安装证书

     openssl req -newkey rsa:3072 -new -x509 -days 3652 -nodes -out cert.pem -keyout key.pem
     mkdir -p ./web/sites/default/files/private/simplesaml/cert
     mv *.pem ./web/sites/default/files/private/simplesaml/cert
    
  9. 检查您的Drupal网站状态报告中的安装,例如 "https://example.com/admin/reports/status"

  10. 访问您的simple saml安装 "身份验证" 选项卡,例如 https://example.com/simplesaml/module.php/core/authenticate.php。应该有一个链接到 default-sp。如果您跟随此链接进入您的IDP上的Drupal登录页面,您就走在正确的轨道上了。

  11. 最后,通知您的IDP新的服务提供商。 在您的IDP系统中,编辑 saml-sp-remote.php 以包含您新SP的域名。

其他注意事项

.htaccess规则用于apache

如果您正在运行apache,您需要在 .htaccess 文件中添加以下内容以授权访问simple saml。

在以下行之前立即添加以下指令

RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]

add the following directives

  # Allow access to simplesamlphp scripts.
  RewriteCond %{REQUEST_URI} !/simplesaml/[^/]*\.php$
  RewriteCond %{REQUEST_URI} !/simplesaml/admin/[^/]*\.php$
  RewriteCond %{REQUEST_URI} !/simplesaml/[^/]*\.php/sanitycheck/[^/]*\.php$
  RewriteCond %{REQUEST_URI} !/simplesaml/[^/]*\.php/drupalauth/[^/]*\.php$
  RewriteCond %{REQUEST_URI} !/simplesaml/[^/]*\.php/core/idp/[^/]*\.php$
  RewriteCond %{REQUEST_URI} !/simplesaml/[^/]*\.php/saml/[^/]*\.php$
  RewriteCond %{REQUEST_URI} !/simplesaml/saml2/idp/[^/]*\.php$
  RewriteCond %{REQUEST_URI} !/simplesaml/saml2/idp/[^/]*\.php/drupal-userpass$
  RewriteCond %{REQUEST_URI} !/simplesaml/[^/]*\.php/saml/sp/[^/]*\.php/default-sp$

本地测试

除了编辑 .htaccess 之外,如果您想本地测试,您还需要编辑 config.php 中的值,以指向您本地的数据库和代码库。