java - Keycloak-6.0.1 自定义 validator SPI

标签 java authentication keycloak keycloak-services

我正在尝试实现一个自定义 keycloack Authenticator SPI,用于针对外部数据源/Rest 服务进行身份验证。计划是将它们迁移到 keycloak 中。

Updated the browser flow(copy and created a new flow and bind it).

First time when the user logs in, will display custom theme login screen.

On submit Using Custom SPI authenticate against external service.

On success create users on the keycloak datasource.

Create custom mappers to add extra user attributes on tokens.

我正在遵循官方指南 https://www.keycloak.org/docs/latest/server_development/index.html#_auth_spi_walkthrough 的第 8.3 节,这和我需要的非常相似。

另外,遵循示例( https://github.com/keycloak/keycloak/tree/master/examples/providers/authenticator )我认为说明并未将其映射到新版本。

例如: 在您的副本中,单击“操作”菜单项和“添加执行”。选择 secret 问题。

In Keycloak-6.0.1, there isn't any such execution as "Pick Secret Question". I really don't need this, but I was atleast trying to set this flow to get hold on how the flow works.

接下来您必须注册您创建的所需操作。单击“身份验证”菜单中的“所需操作”选项卡。单击“注册”按钮并选择新的“所需操作”。

There isn't such Register button on the required action.

我做过的事情。 创造了新境界 注册 UI 客户端 在 keycloak 表的新领域中创建了新用户。 登录时的 UI 重定向到 Keycloak UI 并成功通过身份验证,并且能够使用 JavaScript 适配器成功检索 token

componentDidMount = () => {
        const keycloak = Keycloak('/keycloak.json');
        keycloak.init({onLoad: 'login-required'}).then(authenticated => {
            this.setState({ keycloak: keycloak, authenticated: authenticated })
        })
    }

....
....

if(this.state.keycloak) {
            if(this.state.authenticated) return (
                <div className="contact-body">
                 <p>Name: {this.state.name}</p>
                 <p>Email: {this.state.email}</p>
                 <p>ID: {this.state.id}</p>
               </div>
              );
      }
}

想要使用 Keycloak 登录 UI 功能(如 OTP)以及自定义 validator SPI。在自定义身份 validator SPI 中获取用户名和密码等表单字段,并使用外部服务对其进行身份验证。然后在Keycloak DB中创建用户。

管理员可以在 keycloak 中锁定/暂时暂停某个领域内的用户吗?

我计划使用的另一个选项是,更新 login.ftl onsubmit 将用户名/密码发布到自定义服务,并将 keycloak url 作为查询参数传递。
将根据自定义服务对其进行验证,在 keycloak 数据库上创建用户并重定向到在查询参数上传递的 keycloak url。这似乎不是正确的方法。

任何帮助/想法都会非常有帮助。

最佳答案

这是您正在实现的错误 SPI。 对于外部数据源或服务集成,您必须实现自定义用户存储 SPI

关于java - Keycloak-6.0.1 自定义 validator SPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57470895/

相关文章:

java - Jpanel错误重画

c# - OWIN ASP.NET - 避免在 Web Api 中没有身份的同一帐户多次登录

reactjs - 在 React.JS 中刷新后,如何让用户保持登录到 firebase 的状态?

java - Spring Boot Keycloak - 每个请求验证三次

java - Keycloak:检索所有可用的客户端 session

spring-boot - 如何将Keycloak注册到Spring Eureka Server

java - 运行一段存储在 Java 字符串中的 C 代码

java - Lombok @Data 是否会覆盖现有的 toString 和 hashCode 方法?

java - 是否有简单的方法可以将 String.toLowerCase() 用于 9 种语言?

authentication - 如何设置 IIS 来验证客户端证书并将其作为 http header 传递到后端?