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