1. 修正代码检查流水线运行错误
This commit is contained in:
parent
76525106b4
commit
94d735a1ca
|
@ -54,8 +54,8 @@ spring :
|
||||||
sql :
|
sql :
|
||||||
init:
|
init:
|
||||||
encoding : utf8
|
encoding : utf8
|
||||||
schema-locations: classpath:rbac/schema.sql
|
schema-locations: file:config/rbac/schema.sql
|
||||||
data-locations : classpath:rbac/data.sql
|
data-locations : file:config/rbac/data.sql
|
||||||
# ALWAYS/EMBEDDED/NEVER
|
# ALWAYS/EMBEDDED/NEVER
|
||||||
mode : always
|
mode : always
|
||||||
enabled : true
|
enabled : true
|
||||||
|
@ -64,7 +64,7 @@ spring :
|
||||||
#mybatis
|
#mybatis
|
||||||
mybatis :
|
mybatis :
|
||||||
mapper-locations : classpath*:mappers/*.xml
|
mapper-locations : classpath*:mappers/*.xml
|
||||||
type-aliases-package: com.cmhi.gds.pojo.entry
|
type-aliases-package: com.cf.cs.database.pojo.entry
|
||||||
configuration :
|
configuration :
|
||||||
default-enum-type-handler: com.cf.cs.database.common.DataBaseEnumHandler
|
default-enum-type-handler: com.cf.cs.database.common.DataBaseEnumHandler
|
||||||
|
|
||||||
|
@ -109,3 +109,7 @@ system :
|
||||||
controller:
|
controller:
|
||||||
enabled: false
|
enabled: false
|
||||||
prefix : /dict
|
prefix : /dict
|
||||||
|
|
||||||
|
casbin:
|
||||||
|
model-path: config/casbin/model.conf
|
||||||
|
policy-path: config/casbin/policy.csv
|
|
@ -34,12 +34,12 @@ spring :
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
url : jdbc:mysql://xajhuang.com:3307/common_framework?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
|
url : jdbc:mysql://xajhuang.com:3307/common_framework?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
|
||||||
#url : jdbc:mysql://localhost:3306/common_framework?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
|
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
||||||
username : xajhuang
|
username : xajhuang
|
||||||
password : wkj!nky5cjb!GMV6guq
|
password : wkj!nky5cjb!GMV6guq
|
||||||
|
#url : jdbc:mysql://localhost:3306/common_framework?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
|
||||||
#username : root
|
#username : root
|
||||||
#password : aaaHuang1
|
#password : aaaHuang1
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
dbcp2 :
|
dbcp2 :
|
||||||
max-total : 128
|
max-total : 128
|
||||||
max-wait-millis : 10000
|
max-wait-millis : 10000
|
||||||
|
@ -54,8 +54,8 @@ spring :
|
||||||
sql :
|
sql :
|
||||||
init:
|
init:
|
||||||
encoding : utf8
|
encoding : utf8
|
||||||
schema-locations: classpath:rbac/schema.sql
|
schema-locations: file:../config/rbac/schema.sql
|
||||||
data-locations : classpath:rbac/data.sql
|
data-locations : file:../config/rbac/data.sql
|
||||||
# ALWAYS/EMBEDDED/NEVER
|
# ALWAYS/EMBEDDED/NEVER
|
||||||
mode : always
|
mode : always
|
||||||
enabled : true
|
enabled : true
|
||||||
|
@ -64,7 +64,7 @@ spring :
|
||||||
#mybatis
|
#mybatis
|
||||||
mybatis :
|
mybatis :
|
||||||
mapper-locations : classpath*:mappers/*.xml
|
mapper-locations : classpath*:mappers/*.xml
|
||||||
type-aliases-package: com.cmhi.gds.pojo.entry
|
type-aliases-package: com.cf.cs.database.pojo.entry
|
||||||
configuration :
|
configuration :
|
||||||
default-enum-type-handler: com.cf.cs.database.common.DataBaseEnumHandler
|
default-enum-type-handler: com.cf.cs.database.common.DataBaseEnumHandler
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ pagehelper :
|
||||||
params.count : countSql
|
params.count : countSql
|
||||||
|
|
||||||
#config log
|
#config log
|
||||||
# logging :
|
logging :
|
||||||
# config: file:config/logback.xml
|
config: file:../config/logback.xml
|
||||||
|
|
||||||
log4j :
|
log4j :
|
||||||
logger:
|
logger:
|
||||||
|
@ -109,3 +109,7 @@ system :
|
||||||
controller:
|
controller:
|
||||||
enabled: false
|
enabled: false
|
||||||
prefix : /dict
|
prefix : /dict
|
||||||
|
|
||||||
|
casbin:
|
||||||
|
model-path: ../config/casbin/model.conf
|
||||||
|
policy-path: ../config/casbin/policy.csv
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.cf.cs.authentication.configure;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Casbin configure.
|
||||||
|
*
|
||||||
|
* @author xajhuang @163.com
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "casbin")
|
||||||
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
|
public class CasbinConfigure {
|
||||||
|
private String modelPath;
|
||||||
|
private String policyPath;
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.cf.cs.authentication.misc;
|
package com.cf.cs.authentication.misc;
|
||||||
|
|
||||||
|
|
||||||
|
import com.cf.cs.authentication.configure.CasbinConfigure;
|
||||||
import com.cf.cs.authentication.pojo.po.AuthAccountUser;
|
import com.cf.cs.authentication.pojo.po.AuthAccountUser;
|
||||||
import com.cf.cs.authentication.service.AuthUsersService;
|
import com.cf.cs.authentication.service.AuthUsersService;
|
||||||
import com.cf.cs.database.mapper.RoleMapper;
|
import com.cf.cs.database.mapper.RoleMapper;
|
||||||
|
@ -12,6 +13,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.casbin.jcasbin.main.Enforcer;
|
import org.casbin.jcasbin.main.Enforcer;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -28,6 +32,9 @@ import static com.cf.cs.database.pojo.entity.table.RoleTableDef.ROLE;
|
||||||
public class CasbinAuthorizeUtils {
|
public class CasbinAuthorizeUtils {
|
||||||
private static final ConcurrentHashMap<String, Enforcer> ENFORCER_POOL = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<String, Enforcer> ENFORCER_POOL = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CasbinConfigure casbinConfigure;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AuthUsersService authUsersService;
|
private AuthUsersService authUsersService;
|
||||||
|
|
||||||
|
@ -44,8 +51,10 @@ public class CasbinAuthorizeUtils {
|
||||||
public void init() {
|
public void init() {
|
||||||
roleMapper.selectAll().forEach(role -> {
|
roleMapper.selectAll().forEach(role -> {
|
||||||
if (!CasbinAuthorizeUtils.ENFORCER_POOL.containsKey(role.getName())) {
|
if (!CasbinAuthorizeUtils.ENFORCER_POOL.containsKey(role.getName())) {
|
||||||
String model = Objects.requireNonNull(this.getClass().getResource("/casbin/model.conf")).getFile();
|
String baseDir = System.getProperty("user.dir");
|
||||||
String policy = Objects.requireNonNull(this.getClass().getResource("/casbin/policy.csv")).getFile();
|
String model = baseDir + "/" + casbinConfigure.getModelPath();
|
||||||
|
String policy = baseDir + "/" + casbinConfigure.getPolicyPath();
|
||||||
|
|
||||||
Enforcer e = new Enforcer(model, policy);
|
Enforcer e = new Enforcer(model, policy);
|
||||||
e.enableAutoSave(false);
|
e.enableAutoSave(false);
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,15 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/java</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/rbac/*.*</include>
|
||||||
|
</includes>
|
||||||
|
<filtering>false</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
@ -8,7 +8,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
*
|
*
|
||||||
* @author xajhuang @163.com
|
* @author xajhuang @163.com
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(scanBasePackages = {"com.cf.cs.authentication", "com.cf.cs.restful"})
|
@SpringBootApplication(scanBasePackages = {"com.cf.cs.base", "com.cf.cs.database", "com.cf.cs.protocol",
|
||||||
|
"com.cf.cs.authentication", "com.cf.cs.restful"})
|
||||||
public class CsRestfulApplication {
|
public class CsRestfulApplication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue