spring-boot - 如何使用 saml2.0 在 okta 中配置和获取自定义属性

标签 spring-boot saml-2.0 okta

我在我的应用程序中使用 okta 作为 idp,我想配置自定义属性,例如:ID,如何在 okta 中完成?以及如何在 okta 中设置这些值?

最佳答案

以下是将自定义属性添加到 Okta 的 SAML 断言的过程:

  • 从您的 Okta 组织的仪表板转到管理 -> 目录 -> 配置文件编辑器
  • 在“Okta”配置文件中,选择“配置文件”按钮

  • PROFILE EDITOR
  • 标识您要添加的用户属性的“变量名称”(而不是“显示名称”)值。例如,让我们尝试添加“title”属性。

  • Attribute variable name
  • 导航到“应用程序”选项卡,然后选择您想要将此自定义属性添加到的 SAML 应用程序。
  • 选择“常规”选项卡
  • 在“SAML 设置”设置中,按“编辑”按钮。这应该会启动应用程序配置向导,就好像它是一个新的 SAML 应用程序
  • 按下一步按钮并向下滚动到“属性语句(可选)”部分
  • 按“添加另一个”按钮

  • Add Another SAML attribute
  • 在第一个文本框中,输入您希望在您的应用程序中使用的 SAML 属性的名称,该名称将在您的 SAML 断言中可用(我选择了“jobTitle”)。在第二个文本框中,输入 Okta 配置文件中的变量名称,前缀为“user”。 (例如“user.title”)

  • New SAML attribute
  • 按“下一步”然后“完成”

  • 当您测试您的应用程序时,您应该获得以下 SAML AttributeStatement 节点:
    <saml2:AttributeStatement xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
            <saml2:Attribute Name="firstName"
                             NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
                             >
                <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                      xsi:type="xs:string"
                                      >Isaac</saml2:AttributeValue>
            </saml2:Attribute>
            <saml2:Attribute Name="lastName"
                             NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
                             >
                <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                      xsi:type="xs:string"
                                      >Brock</saml2:AttributeValue>
            </saml2:Attribute>
            <saml2:Attribute Name="Email"
                             NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
                             >
                <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                      xsi:type="xs:string"
                                      >isaac.brock@mailinator.com</saml2:AttributeValue>
            </saml2:Attribute>
            <saml2:Attribute Name="userName"
                             NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
                             >
                <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                      xsi:type="xs:string"
                                      >isaac@company.com</saml2:AttributeValue>
            </saml2:Attribute>
            <saml2:Attribute Name="phone"
                             NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
                             >
                <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                      xsi:type="xs:string"
                                      >+1 415 456 7893</saml2:AttributeValue>
            </saml2:Attribute>
            <saml2:Attribute Name="jobTitle"
                             NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
                             >
                <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                      xsi:type="xs:string"
                                      >Vice President</saml2:AttributeValue>
            </saml2:Attribute>
        </saml2:AttributeStatement>
    

    (注意最后一个“jobTitle”属性)

    我希望这有帮助!

    关于spring-boot - 如何使用 saml2.0 在 okta 中配置和获取自定义属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40458134/

    相关文章:

    asp.net - 使用针对 asp.net 的 WSFederationAuthenticationModule 对多个身份提供者进行身份验证

    node.js - 使用 Okta OIDC 中间件时获取 "Error: state mismatch, could not find a state in the session"

    java - java 6 项目中的 onelogin java saml 2.0

    logging - Kentor authservices 和 log4net

    ssl - 如何使用 SSL 让网站在 Okta 上与 SAML 一起工作

    java - SAML 2.0 支持 Java Jersey Web/REST 应用程序

    java - 找不到 mongoTemplate bean

    java - Spring Cloud微服务,与其他微服务一起使用受密码保护的微服务

    angularjs - 无法理解 JWT 和 Java (Spring Boot)。这个应用程序安全吗?

    java - 如何在没有嵌入式数据源配置的情况下在 spring boot 测试期间执行 `schema.sql`?