【问题标题】:Retrieving username and details form SAMLResponse从 SAMLResponse 中检索用户名和详细信息
【发布时间】:2015-05-31 10:05:15
【问题描述】:

我使用 ssocircle 作为我的 IDP。 如何获取用户名作为响应任何代码示例都会有所帮助。 我的 saml 请求如下。

<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
                     AssertionConsumerServiceURL="http://localhost:38080/ICDWeb/saml/SSO"
                     Destination="https://idp.ssocircle.com:443/sso/SSORedirect/metaAlias/ssocircle"
                     ForceAuthn="false"
                     ID="a3h6ehei2fjhghi3240a10e2ad03ifj"
                     IsPassive="false"
                     IssueInstant="2015-03-27T06:12:49.597Z"
                     ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
                     Version="2.0"
                     >
    <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">http://172.16.246.146:38080:ICDWeb/saml/metadata</saml2:Issuer>
</saml2p:AuthnRequest>

【问题讨论】:

  • 我收到邮件 ID 作为委托人,但我需要用户名
  • 您需要做什么才能让 SSO Circle 将用户名作为主体发送给您?
  • 在上传 SP 元数据时,您可以勾选用户 ID 复选框,您可以在 ssocircle 元数据上传页面找到该复选框。这将在用户 id 属性的 saml 响应中向您发送断言中的用户名。

标签: spring-saml


【解决方案1】:

您需要配置您的 IDP 以发送您需要的属性。

在 SP 端,您可以加载 IDP 从 SAMLCredential 对象发送的属性,该对象在 SecurityContextHolder.getContext().getAuthentication().getCredentials() 中可用。打电话给例如credential.getAttributeAsString("myAttribute") 将返回 IDP 发送的值。 IDP 发送的NameID 值可用作SecurityContextHolder.getContext().getAuthentication().getPrincipal() 中的主体。

【讨论】:

    猜你喜欢
    • 2018-05-21
    • 1970-01-01
    • 2012-09-26
    • 1970-01-01
    • 1970-01-01
    • 2020-08-28
    • 1970-01-01
    • 2011-03-06
    • 2021-02-03
    相关资源
    最近更新 更多