Shibboleth将用户名返回为HTTP Header而不是SAML属性

时间:2016-09-29 20:41:26

标签: http-headers saml saml-2.0 shibboleth

Shibboleth IDP和SP说得很好,我需要的数据在SAML中。

允许shibboleth返回带有我需要的信息的HTTP标头需要什么配置(是的,我知道这是一个坏主意但不能做出选择)。

我在IIS上运行SP 2.6,并且在shibboleth3 IDP响应中需要一个带有用户名的HTTP标头。

这是我为attribute-map.xml

尝试的内容
<Attribute name="urn:oid:1.3.6.1.4.1.5923.1.1.1.6" id="netId" nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"/>

它在SAML中为我提供了这些数据

 <saml2:AttributeStatement>
        <saml2:Attribute FriendlyName="eduPersonPrincipalName"
                         Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.6"
                         NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
            <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                  xsi:type="xsd:string">me@school.edu</saml2:AttributeValue>
        </saml2:Attribute>
    </saml2:AttributeStatement>

由于我正在使用的软件,我需要HTTP标头中的用户名。

1 个答案:

答案 0 :(得分:2)

您无法让Identity Provider发布HTTP标头。这不是SAML Web浏览器SSO配置文件。

您已经拥有了正在讨论的中间件,它是Shibboleth服务提供商,如果您的attribute-map.xml文件正确,您将能够从应用程序逻辑中访问属性作为env变量或http头正如所描述的here

如何将属性映射到HTTP标头的示例如下:

让我们说你

  • 从IdP发布SAML名称为urn:oid:1.3.6.1.4.1.5923.1.1.1.6的属性

  • 您在SP attribute-map.xml中的
  • 有一个属性解码器,如:

<Attribute name="urn:oid:1.3.6.1.4.1.5923.1.1.1.6" id="netId" nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"/>

考虑到

  

使用标题时,主要区别在于,应用程序必须在其前面加上“HTTP_”,而不是使用通过映射过程定义的名称,并且在大多数工具中也会使名称的其余部分更新。

HTTP标头最终将为HTTP_NETID

关于如何阅读标题值,如this thread

中所述
  

迭代所有传递的内容:

     

foreach (string key in Request.ServerVariables.AllKeys)

     

引用特定值:

     

value = Request.ServerVariables[key];