信息散列中的 omniauth-saml nil 值

omniauth-saml nil values in info hash

我正在按照 https://github.com/PracticallyGreen/omniauth-saml and the omniauth Facebook example https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview

的说明使用 devise 和 omniauth-saml

我有一个 simplesamlphp 服务器 运行,使用 omniauth 提供的元数据,一切似乎都连接正常,但来自 simplesaml 服务器的响应没有电子邮件值,first_name, last_name 和姓名。奇怪的是它返回了电子邮件和姓名值,只是不在响应的有用部分(见下文 - super@man.com 是电子邮件,Clark Kent 是名字)

奇怪的是,我通过 omniauth-saml 和 devise-saml-authenticatable gems 获得了这些 nil 值,但我认为我的 simplesamlphp 服务器配置正确。

omniauth 的响应如下所示:

#<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash> extra=#<OmniAuth::AuthHash raw_info=#<OneLogin::RubySaml::Attributes:0x007fc695850148 @attributes={"urn:oid:0.9.2342.19200300.100.1.1"=>["super@man.com"], "urn:oid:2.16.840.1.113730.3.1.241"=>["Clark Kent"], "fingerprint"=>"FINGERPRINT REMOVED"}>> info=#<OmniAuth::AuthHash::InfoHash email=nil first_name=nil last_name=nil name=nil> provider="saml" uid="_ca76f49ccb6ccce7827111ae1ff0563f534f0a4d1a">

simplesamlphp 配置如下所示:

$metadata['http://localhost:3000/saml/users/auth/saml/metadata'] = array( 'AssertionConsumerService' => 'http://localhost:3000/saml/users/auth/saml/callback', 'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:email', 'simplesaml.nameidattribute' => 'email', );

我确信数据库中的用户有很好的价值,当我测试 IDP 本身的身份验证时,一切都按预期工作。

我解决了这个问题。问题是我试图使用不使用 ldap 属性名称的值。

我如下更改了我的 sp 元数据(在修改我的模型以使用 first_name 和 last_name 而不仅仅是名称之后)

$metadata['http://localhost:3000/saml/users/auth/saml/metadata'] = array(
'AssertionConsumerService' => 'http://localhost:3000/saml/users/auth/saml/callback',
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:email',
'authproc' => array(
95 => array(
    'class' => 'core:AttributeMap',
    'givenName' => 'first_name',
    'sn' => 'last_name',
    'mail' => 'email',
),
96 => array(
    'class' => 'core:AttributeLimit',
    'email', 'first_name', 'last_name'
),
),
'simplesaml.nameidattribute' => 'email',
);