【问题标题】:Shibboleth - How to read attributes?Shibboleth - 如何读取属性?
【发布时间】:2013-09-01 06:28:22
【问题描述】:

我正在使用 Shibboleth 成功登录到我的服务提供商测试页面。然后我转到 /Shibboleth.sso/Session 页面,看到以下内容:

Attributes
affiliation: 1 value(s)
entitlement: 1 value(s)
eppn: 1 value(s)
persistent-id: 1 value(s)
unscoped-affiliation: 1 value(s)

我的问题是……我该如何阅读这些价值观?我在 Fiddler 的 HTTP 请求标头中没有看到它们。

我的 Web 应用程序将在 ASP.NET MVC 4 (C#) 中实现。

【问题讨论】:

    标签: attributes shibboleth


    【解决方案1】:

    您还可以在shibboleth2.xml 的会话处理程序中将showAttributeValues 设置为true。请注意,不建议在生产环境中这样做。然后重启shibboleth服务;会话页面的属性部分将包含实际值。

    <!-- Session diagnostic service. -->
    <Handler type="Session" Location="/Session" showAttributeValues="true"/>
    

    【讨论】:

      【解决方案2】:

      您可以使用 Request.ServerVariables 对象读取 IdP 发送的 Shibboleth SAML 属性:

      string server = Request.ServerVariables["HTTP_FIRSTNAME"];
      

      如果您想列出并打印会话中的所有属性,请参阅this

      记得配置 Shibboleth attribute-map.xml 以处理您的 IdP 可能发送的自定义属性:

      <Attribute name="firstname" id="firstname" nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
          <AttributeDecoder xsi:type="StringAttributeDecoder"/>
      </Attribute>
      

      【讨论】:

        【解决方案3】:

        既然你提到了提琴手,我会继续补充(问题发生多年后),有一个非常好的 Firefox 浏览器插件,名为“SAML 跟踪器”。 (只需搜索“saml tracer”,您就会找到它的 mozilla 插件页面。)一旦安装在 firefox 中,您可以打开它的窗口,它会显示所有 http 请求和响应。如果其中有 saml,它将在 url 旁边带有“SAML”标签;然后您可以单击该 url,选择“SAML”选项卡,然后阅读在 idp 或 sp 与您的浏览器之间发送的所有 saml。它是一个非常棒的在线故障排除工具,因此您不必弄乱 sp 和/或 idp 上的任何东西(甚至可以访问它们)。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-12-22
          • 2017-03-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-10-18
          • 1970-01-01
          相关资源
          最近更新 更多