2015-12-14 415 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。

相关问题