2015-12-14 412 views
2

我們在Camunda BPM中部署了基於Spring的應用程序。我們在這裏使用Camunda JAVA API暴露了一些REST服務。我們在沒有Camunda REST api的情況下做了一些特定的要求。這些自定義REST服務正在運行,不需要授權&授權。我能夠通過這些服務創建/完成/刪除進程&任務,而無需對有效用戶進行身份驗證。我想知道如何強制Camunda Java apis在執行之前查找經過身份驗證的用戶。我正在使用Camunda BPM 7.3。如何在Camunda Java api中強制進行身份驗證?

回答

4

我找到了答案。這種情況下的身份驗證在我們手中。我們必須以任何我們想要的方式對用戶進行身份驗證,然後在identityService中設置經過身份驗證的userId。如果經過身份驗證的用戶爲空,則也會跳過authroization檢查。因此,我的代碼沒有驗證工作。

登記AuthorizationManager類下面的代碼 -

public void checkAuthorization(List<PermissionCheck> permissionChecks) { 
     Authentication currentAuthentication = getCurrentAuthentication(); 
     CommandContext commandContext = getCommandContext(); 

     if(isAuthorizationEnabled() && currentAuthentication != null && commandContext.isAuthorizationCheckEnabled()) { 

     String userId = currentAuthentication.getUserId(); 
     boolean isAuthorized = isAuthorized(userId, currentAuthentication.getGroupIds(), permissionChecks); 

     ........... 
     ....... 

如從IF條件是顯而易見的,如果currentAuthentication是空的isAuthroized()方法將不被調用。

要記住的另一件事是在bpm-platform.xml中,我們已經定義了ProcessEngineConfiguration,我們需要將authorizationEnabled屬性設置爲true。

相關問題