gpt4 book ai didi

java - 将 Spring Security 连接到 Camunda 引擎,要覆盖什么?

转载 作者:行者123 更新时间:2023-12-01 12:12:46 25 4
gpt4 key购买 nike

我成功集成了 Spring 安全 Camunda的身份服务 .
我的目标是在两者之间共享一个共同的身份验证领域,因为我们有一个 Spring Boot 基于网络应用程序,也运行 camunda。
在我们的应用程序中,Spring Security 应该单独管理单个身份验证领域,将 Camunda 仅充当只读客户端代码。

我们计划将业务流程与用户绑定(bind),这些用户应该通过spring security进行身份验证。

我的问题是我应该确切地实现/覆盖什么?

我目前的代码如下:

import org.camunda.bpm.engine.impl.identity.db.DbReadOnlyIdentityServiceProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;

/**
* Wires Camunda {@link org.camunda.bpm.engine.IdentityService} with Spring Security.
* TODO check if other method overrides are needed
*/
@Component
public class SpringSecurityReadOnlyIdentityServiceProvider extends DbReadOnlyIdentityServiceProvider {

@Autowired
private AuthenticationManager authenticationManager;

/**
* Checks if username and password is valid.
*
* @param userId Username
* @param password Password
* @return True if authentication succeeded
*/
@Override
public boolean checkPassword(String userId, String password) {
try {
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(userId, password));
} catch (AuthenticationException e) {
return false;
}
return true;
}
}

它有效(接线本身),但我不知道我应该覆盖哪些更多方法。

此代码检查给定的用户名和密码在 Spring Security 的领域中是否正确。这够了吗?
我确实阅读了 Camunda 的文档。它包含大约两行说我应该实现 ReadOnlyIdentityProvider WritableIdentityProvider ,但我认为实现每一种方法都是矫枉过正的。这就是我扩展 的原因DbReadOnlyIdentityServiceProvider .

谢谢!

最佳答案

与此同时,Camunda 7.9 引入了 ContainerBasedAuthenticationFilter,它可以与自定义的 Camunda AuthenticationProvider 结合使用。

这是将 Camunda >=7.9 与 Spring Security 集成的完整示例:
https://github.com/camunda-consulting/code/tree/master/snippets/springboot-security-sso

关于java - 将 Spring Security 连接到 Camunda 引擎,要覆盖什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42275660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com