Authentication 如何在Camunda Java api中强制进行身份验证?

Authentication 如何在Camunda Java api中强制进行身份验证?,authentication,camunda,Authentication,Camunda,我们在Camunda BPM中部署了一个基于Spring的应用程序。我们在这里使用Camunda JAVA api公开了一些REST服务。我们这样做是为了满足一些特定的需求,在这些需求中,我们没有可用的Camunda REST api。这些自定义REST服务在没有身份验证和授权的情况下运行。我能够通过这些服务创建/完成/删除流程和任务,而无需验证有效用户。我想知道如何强制camundajavaapi在执行之前查找经过身份验证的用户。我正在使用Camunda BPM 7.3。我找到了答案。本例中的

我们在Camunda BPM中部署了一个基于Spring的应用程序。我们在这里使用Camunda JAVA api公开了一些REST服务。我们这样做是为了满足一些特定的需求,在这些需求中,我们没有可用的Camunda REST api。这些自定义REST服务在没有身份验证和授权的情况下运行。我能够通过这些服务创建/完成/删除流程和任务,而无需验证有效用户。我想知道如何强制camundajavaapi在执行之前查找经过身份验证的用户。我正在使用Camunda BPM 7.3。

我找到了答案。本例中的身份验证由我们负责。我们必须以任何方式对用户进行身份验证,然后在identityService中设置经过身份验证的用户ID。如果经过身份验证的用户为空,则也将跳过身份验证检查。因此,我的代码在没有身份验证的情况下工作

在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);

        ...........
        .......
公共作废检查授权(列出权限检查){
Authentication currentAuthentication=getCurrentAuthentication();
CommandContext CommandContext=getCommandContext();
if(isAuthorizationEnabled()&¤tAuthentication!=null&&commandContext.isAuthorizationCheckEnabled()){
字符串userId=currentAuthentication.getUserId();
布尔值isAuthorized=isAuthorized(userId,currentAuthentication.getGroupId(),permissionChecks);
...........
.......
从IF条件可以明显看出,如果currentAuthentication为null,则不会调用isAuthroized()方法

另一件需要记住的事情是在bpm-platform.xml中,我们定义了ProcessEngineConfiguration,我们需要将authorizationEnabled属性设置为true