【发布时间】:2017-02-16 13:42:54
【问题描述】:
我成功地将 Spring Security 与 Camunda 的 IdentityService 集成。 我的目标是在两者之间共享一个共同的身份验证领域,因为我们有一个基于 spring-boot 的网络应用程序,它也运行 camunda。 在我们的应用程序中,Spring Security 应该单独管理单个身份验证领域,仅将 Camunda 充当只读客户端代码。
我们正在计划将业务流程与用户绑定,这些用户应该通过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 的原因。
谢谢!
【问题讨论】:
标签: java spring spring-boot business-process-management camunda