使用 devise_saml_authenticatable 在 Rails 中使用 Onelogin 进行 SAML 登录会给出 NoMethodError - nil:NilClass 的未定义方法“to_sym”

问题描述 投票:0回答:0

我在 Ruby(2.0) on Rails(4) 上工作,正在测试与 Onelogin 作为身份提供者的 SAML 集成。我正在使用devise_saml_authenticatable gem(v 1.5.0)。

我按照这个 wiki 在 Onelogin 上创建了一个示例 IdP 连接器。 Devise::SamlSessionsController#create 首先查找 attribute-map.yml(如果未添加)。添加 attribute-map.yml 后,我收到错误 - nil:NilClass 的未定义方法“to_sym” - 当我尝试在我的控制器代码中使用任何设计助手(例如 current_user、user_signed_in?)时。 根据我解码的 SAML 响应,我的 SAML 属性(我正在接收 - 电子邮件、用户名、名称)的格式是 - urn:oasis:names:tc:SAML:2.0:attrname-format:basic - 这意味着简单字符串值作为键。但我也尝试了我的 attribute-map.yml 的其他以下版本,因为我刚刚开始学习使用此协议。

属性映射.yml - 1

电子邮件:“电子邮件” 用户名:“用户名” 名称:“名称”

属性映射.yml - 2

"urn:oasis:names:tc:SAML:2.0:attrname-format:email": "email" "urn:oasis:names:tc:SAML:2.0:attrname-format:username": "username" "urn:oasis:names:tc:SAML:2.0:attrname-format:name": "name"

属性映射.yml - 3

"urn:mace:dir:attribute-def:email": "email" "urn:mace:dir:attribute-def:username": "username" "urn:mace:dir:attribute-def:name": "name"

我猜我的用户模型字段的属性映射存在一些问题,这些字段是 - email、name、username

我尝试正确解码 SAML 响应并使用不同版本的 attribute-map.yml 文件,但是

current_user
似乎仍然没有创建。

ruby-on-rails devise single-sign-on saml-2.0 onelogin
© www.soinside.com 2019 - 2024. All rights reserved.