Shibboleth SSO 与 Discourse

大家好,

我终于将我的 Discourse 站点与 Shibboleth 集成成功了。其实很简单……只要搞明白之后 :joy:

  1. 在一台 Web 服务器上部署 Shibboleth(不必与 Discourse 服务器相同)。我们称其为 shib.univ.edu

  2. shib.univ.edu 上创建一个目录用于处理 Discourse SSO。我们称其为 discourse-sso

  3. 使用 Shibboleth 保护该目录。如果您使用的是 Apache,通常意味着在 discourse-sso/.htaccess 中添加类似以下内容:

     # Shibboleth 头部
     AuthType Shibboleth
     ShibRequireSession On
     ShibApplicationId default
     ShibExportAssertion On
    
     require shib-user ~ ^.+@univ\.edu$
    
  4. 获取一个库来执行 Discourse 官方 SSO 指南 中描述的签名工作。我使用的是 cviebrock/discourse-php。按照使用说明复制并创建 sso.php 文件。

  5. 您的 usernameemail 将存储在环境变量 eppn 中。因此,如果您按照 cviebrock/discourse-php(见上方链接)中的使用说明操作,只需设置:

     // 在此处插入您的用户认证代码 ...
     // 必需,且必须与您的应用保持一致
     $userEmail = getenv( 'eppn' );
    
     // 必需,且必须对您的应用唯一
     $userId = strstr( $userEmail, '@', true );
    
  6. 根据 Discourse 官方 SSO 指南启用 SSO。将您的 sso url 指向 https://shib.univ.edu/discourse-sso/sso.php,即可正常使用。

GI

7 个赞