【问题标题】:Need to add Attributes in AuthNRequest.. How can this be done?需要在 AuthNRequest 中添加 Attributes .. 怎么做?
【发布时间】:2021-08-18 09:50:25
【问题描述】:

如何在 C# 中使用 itfoxtec-identity-saml2 将此示例添加到断言中?找不到合适的方法...

<saml:AttributeStatement>
<saml:Attribute FriendlyName="SurName" Name="urn:oid:2.5.4.4" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
  <saml:AttributeValue xsi:type="xs:string">Max</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute FriendlyName="CommonName" Name="urn:oid:2.5.4.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
  <saml:AttributeValue xsi:type="xs:string">Max Mustermann</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute Name="urn:oid:0.9.2342.19200300.100.1.1" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
  <saml:AttributeValue xsi:type="xs:string">has</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute FriendlyName="Email" Name="urn:oid:0.9.2342.19200300.100.1.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
  <saml:AttributeValue xsi:type="xs:string">max@mustermann.de</saml:AttributeValue>
</saml:Attribute>  </saml:AttributeStatement>

【问题讨论】:

  • 您想在 AuthnRequest 中添加 AttributeStatement 还是在 AuthnResponse 中发出的 Assertion 中添加?
  • 据我了解,这将与 AuthNRequest 一起发送并在 AuthNResponse 中发出的断言中返回
  • AuthnResponse 中 Assertion 中的 AttributeStatements 由 IdP 发出。作为 RP,您只能提供意向声明。
  • 但在 itfoxtec-identity-saml2 的测试应用程序中,TestIdPCore 项目充当 IdP。如何配置它以传递这些属性?
  • 你的意思是我应该用这个属性扩展依赖方?

标签: itfoxtec-identity-saml2


【解决方案1】:

可以在示例 IdP 中向已发布的断言添加更多声明/属性。

测试用户声明已添加到 https://github.com/ITfoxtec/ITfoxtec.Identity.Saml2/blob/master/test/TestIdPCore/Controllers/AuthController.cs#L173

您可以添加所需的声明/属性,然后将在 AuthnResponse 断言中发布。

【讨论】:

  • 这不是在断言的 标记中定义的自定义属性。声明取决于 System.Security.Claims 命名空间中给定的声明类型
  • 您不限于使用 System.Security.Claims 中定义的声明类型,您可以使用自己的自定义声明类型。
【解决方案2】:

声明仅限于 System.Security.Claims 命名空间中定义的声明类型:

在 ComponentsPro 中 Saml 实现属性是这样添加的:

 AttributeStatement attributeStatement = new AttributeStatement();
attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("email", SamlAttributeNameFormat.Basic, null,
                                                                             "john@test.com"));
attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("FirstName", SamlAttributeNameFormat.Basic, null,
                                                                             "John"));
attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("LastName", SamlAttributeNameFormat.Basic, null,
                                                                             "Smith"));

// Insert a custom token key to the SAML response.
attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("CustomTokenForVerification", SamlAttributeNameFormat.Basic, null,
                                                                             "YourEncryptedTokenHere"));

samlAssertion.Statements.Add(attributeStatement);

在 Pingfederates 身份服务提供者连接中,需要定义自定义属性。这似乎不是索赔?

【讨论】:

    猜你喜欢
    • 2019-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多