大家好,
我终于将我的 Discourse 站点与 Shibboleth 集成成功了。其实很简单……只要搞明白之后
。
-
在一台 Web 服务器上部署 Shibboleth(不必与 Discourse 服务器相同)。我们称其为
shib.univ.edu。 -
在
shib.univ.edu上创建一个目录用于处理 Discourse SSO。我们称其为discourse-sso。 -
使用 Shibboleth 保护该目录。如果您使用的是 Apache,通常意味着在
discourse-sso/.htaccess中添加类似以下内容:# Shibboleth 头部 AuthType Shibboleth ShibRequireSession On ShibApplicationId default ShibExportAssertion On require shib-user ~ ^.+@univ\.edu$ -
获取一个库来执行 Discourse 官方 SSO 指南 中描述的签名工作。我使用的是 cviebrock/discourse-php。按照使用说明复制并创建
sso.php文件。 -
您的
username和email将存储在环境变量eppn中。因此,如果您按照 cviebrock/discourse-php(见上方链接)中的使用说明操作,只需设置:// 在此处插入您的用户认证代码 ... // 必需,且必须与您的应用保持一致 $userEmail = getenv( 'eppn' ); // 必需,且必须对您的应用唯一 $userId = strstr( $userEmail, '@', true ); -
根据 Discourse 官方 SSO 指南启用 SSO。将您的
sso url指向https://shib.univ.edu/discourse-sso/sso.php,即可正常使用。
GI