flowable 6.6.0 更新變動,相對於6.5.0版本,導致流程設計器免登錄驗證失敗


前沿:

flowable和activiti是同一個團隊開發的,activiti先,flowable后 。所以,flowable 算是 activiti的升級版。
flowable 確實要比activiti功能更完善。未來肯定flowable 是主流趨勢,當下也已經是主流了。

目前最新版本的 flowable 6.6.0 版本,相對於6.5.0版本配置的免登錄方案,對6.6.0版本就無效了

通過查看對比flowable源碼,發現內置的 Security 權限代碼有不少改動,這個是導致免登陸失敗的根源

需要重新重構flowable源碼的兩個函數,如下

1. SecurityUtils

package org.flowable.ui.common.security;

import org.fh.util.Jurisdiction;
import org.flowable.common.engine.api.FlowableIllegalStateException;
import org.flowable.idm.api.User;
import org.flowable.ui.common.model.RemoteUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * 說明:重構流程編輯器獲取用戶信息
 * 作者:FH Admin
 * from:www.fhadmin.org
 */
public class SecurityUtils {

	private static User assumeUser;
	
	private static SecurityScopeProvider securityScopeProvider = new FlowableSecurityScopeProvider();

	private SecurityUtils() {
	}

	/**
	 * Get the login of the current user.
	 */
	public static String getCurrentUserId() {
		User user = getCurrentUserObject();
		if (user != null) {
			return user.getId();
		}
		return null;
	}

	/**
	 * @return the {@link User} object associated with the current logged in user.
	 */
	public static User getCurrentUserObject() {
		if (assumeUser != null) {
			return assumeUser;
		}

		RemoteUser user = new RemoteUser();
		user.setId(Jurisdiction.getUsername());
		user.setDisplayName(Jurisdiction.getName());
		user.setFirstName(Jurisdiction.getName());
		user.setLastName(Jurisdiction.getName());
		user.setEmail("admin@flowable.com");
		user.setPassword("123456");
		List<String> pris = new ArrayList<>();
		pris.add(DefaultPrivileges.ACCESS_MODELER);
		pris.add(DefaultPrivileges.ACCESS_IDM);
		pris.add(DefaultPrivileges.ACCESS_ADMIN);
		pris.add(DefaultPrivileges.ACCESS_TASK);
		pris.add(DefaultPrivileges.ACCESS_REST_API);
		user.setPrivileges(pris);
		return user;
	}
	
    public static void setSecurityScopeProvider(SecurityScopeProvider securityScopeProvider) {
        SecurityUtils.securityScopeProvider = securityScopeProvider;
    }

    public static SecurityScope getCurrentSecurityScope() {
        SecurityContext securityContext = SecurityContextHolder.getContext();
        if (securityContext != null && securityContext.getAuthentication() != null) {
            return getSecurityScope(securityContext.getAuthentication());
        }
        return null;
    }

    public static SecurityScope getSecurityScope(Authentication authentication) {
        return securityScopeProvider.getSecurityScope(authentication);
    }

    public static SecurityScope getAuthenticatedSecurityScope() {
        SecurityScope currentSecurityScope = getCurrentSecurityScope();
        if (currentSecurityScope != null) {
            return currentSecurityScope;
        }
        throw new FlowableIllegalStateException("User is not authenticated");
    }

	public static void assumeUser(User user) {
		assumeUser = user;
	}

	public static void clearAssumeUser() {
		assumeUser = null;
	}
}

2.FlowableUiSecurityAutoConfiguration

package org.flowable.ui.common.security;

import org.flowable.spring.boot.FlowableSecurityAutoConfiguration;
import org.flowable.spring.boot.idm.IdmEngineServicesAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration;
import org.springframework.context.annotation.Configuration;

/**
 * 說明:重構FlowableUiSecurity自動配置
 * 作者:FH Admin
 * from:www.fhadmin.org
 */
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter({
        IdmEngineServicesAutoConfiguration.class,
})
@AutoConfigureBefore({
        FlowableSecurityAutoConfiguration.class,
        OAuth2ClientAutoConfiguration.class,
})
public class FlowableUiSecurityAutoConfiguration {}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM