我们在Camunda BPM中部署了基于Spring的应用程序。我们使用Camunda JAVA api在这里公开了一些REST服务。我们针对某些特定要求执行了此操作,因为我们没有可用的Camunda REST API。这些自定义REST服务无需身份验证即可运行。授权。我能够创建/完成/删除进程&通过这些服务完成任务而无需验证有效用户。我想知道如何强制Camunda Java apis在执行之前查找经过身份验证的用户。我正在使用Camunda BPM 7.3。
答案 0 :(得分:4)
我找到了答案。在这种情况下的身份验证在我们手中。我们必须以任何方式验证用户身份,然后在identityService中设置经过身份验证的userId。如果经过身份验证的用户为null,则还会跳过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为null,则不会调用isAuthroized()方法。
要记住的另一件事是在bpm-platform.xml中我们已经定义了我们需要将authorizationEnabled属性设置为true的ProcessEngineConfiguration。