【问题标题】:Wiring Spring Security into Camunda Engine, what to override?将 Spring Security 连接到 Camunda 引擎,要覆盖什么?
【发布时间】:2017-02-16 13:42:54
【问题描述】:

我成功地将 Spring SecurityCamunda 的 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 的文档。它包含大约两行说我应该实现 ReadOnlyIdentityProviderWritableIdentityProvider,但我认为实现每一个方法都是矫枉过正。这就是我扩展 DbReadOnlyIdentityServiceProvider 的原因。

谢谢!

【问题讨论】:

    标签: java spring spring-boot business-process-management camunda


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2018-09-17
      • 2015-12-20
      • 2015-04-07
      • 1970-01-01
      • 2018-05-13
      • 1970-01-01
      • 2011-09-16
      • 2010-11-03
      • 2014-09-20
      相关资源
      最近更新 更多