簡體   English   中英

將 Spring Security 連接到 Camunda 引擎,要覆蓋什么?

[英]Wiring Spring Security into Camunda Engine, what to override?

我成功地將Spring SecurityCamunda 的 IdentityService集成在一起。 我的目標是在兩者之間共享一個共同的身份驗證領域,因為我們有一個基於spring-boot的 web 應用程序,它也運行 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的原因。

謝謝!

與此同時,Camunda 7.9 引入了 ContainerBasedAuthenticationFilter,可與自定義 Camunda AuthenticationProvider 結合使用。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM