diff --git a/.gitignore b/.gitignore
index 44c3ee73..6adb501a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ build
dist
wedpr-components/user/src/main/resources/
wedpr-adm/src/main/resources/
+wedpr-admin/src/main/resources/
logs/
diff --git a/db/wedpr_dml.sql b/db/wedpr_dml.sql
index 0cd8fd25..d86e3b2a 100644
--- a/db/wedpr_dml.sql
+++ b/db/wedpr_dml.sql
@@ -13,6 +13,6 @@ values("9112736673759237", "wedpr_data_auth", "数据审批模板", '{"name":"we
insert into wedpr_group (group_id, group_name, admin_name, status) values('1000000000000000', '初始用户组', 'admin', 0);
insert into wedpr_group_detail (group_id, username, status) values('1000000000000000', 'admin', 0);
insert into wedpr_user (username, password, status) values('admin', '{bcrypt}$2a$10$9ZhDOBp.sRKat4l14ygu/.LscxrMUcDAfeVOEPiYwbcRkoB09gCmi', 0);
-insert into wedpr_user_role(username, role_id) values ('admin', 1);
+insert into wedpr_user_role(username, role_id) values ('admin', '1');
insert into wedpr_role_permission (role_id, role_name, permission_id) values ('1', 'admin_user', '1')
insert into wedpr_role_permission (role_id, role_name, permission_id) values ('2', 'original_user', '2')
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index ce78ca7e..64e8efac 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -68,4 +68,6 @@ project(":wedpr-components-initializer").projectDir=file("wedpr-components/initi
include "wedpr-adm"
project(":wedpr-adm").projectDir=file("wedpr-adm")
+include 'wedpr-admin'
+project(":wedpr-admin").projectDir=file("wedpr-admin")
diff --git a/wedpr-admin/build.gradle b/wedpr-admin/build.gradle
new file mode 100644
index 00000000..a6595203
--- /dev/null
+++ b/wedpr-admin/build.gradle
@@ -0,0 +1,17 @@
+// Apply the java-library plugin to add support for Java Library
+plugins {
+ id 'java'
+ id 'com.github.sherter.google-java-format'
+}
+
+dependencies {
+ compile project(":wedpr-components-initializer")
+ compile project(":wedpr-components-security")
+}
+googleJavaFormat {
+ //toolVersion = '1.7'
+ options style: 'AOSP'
+ source = sourceSets*.allJava
+ include '**/*.java'
+ //source = *.allJava
+}
\ No newline at end of file
diff --git a/wedpr-admin/conf/application.properties b/wedpr-admin/conf/application.properties
new file mode 100644
index 00000000..3786f27c
--- /dev/null
+++ b/wedpr-admin/conf/application.properties
@@ -0,0 +1,27 @@
+server.port=6850
+
+spring.profiles.include=mysql
+server.shutdown=graceful
+spring.lifecycle.timeout-per-shutdown-phase=30s
+
+logging.level.root=INFO
+
+# mybatis sql log
+mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
+
+jackson.date-format =yyyy-MM-dd HH:mm:ss
+jackson.time-zone =GMT+8
+
+# USER
+wedpr.user.jwt.secret=123456
+# ms
+wedpr.user.jwt.expireTime=3600000
+wedpr.user.jwt.delimiter=|
+wedpr.user.jwt.cacheSize=10000
+wedpr.user.jwt.privateKey=
+wedpr.user.jwt.publicKey=
+wedpr.user.jwt.sessionKey=
+
+springfox.documentation.enabled=false
+
diff --git a/wedpr-admin/conf/log4j2.xml b/wedpr-admin/conf/log4j2.xml
new file mode 100644
index 00000000..f900906d
--- /dev/null
+++ b/wedpr-admin/conf/log4j2.xml
@@ -0,0 +1,89 @@
+
+
+
+
+ info
+
+ ./logs/ppcs-admin
+
+ ppcs-admin
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wedpr-admin/conf/wedpr.properties b/wedpr-admin/conf/wedpr.properties
new file mode 100644
index 00000000..28b84bce
--- /dev/null
+++ b/wedpr-admin/conf/wedpr.properties
@@ -0,0 +1,21 @@
+#### the uuid related configuration
+# the worker id bit len
+wedpr.uuid.generator.worker.id.bit.len=6
+# the seq bit length
+wedpr.uuid.generator.seq.bit.length=10
+# the worker id, Note: must in range[0, 2^6)
+wedpr.uuid.generator.worker.id=10
+
+# use dpm or not
+wedpr.enable.dpm = false
+
+wedpr.mybatis.url=jdbc:mysql://127.0.0.1/wedpr3?characterEncoding=UTF-8&allowMultiQueries=true
+#wedpr.mybatis.username=[*user_ppcs_modeladm]
+#wedpr.mybatis.password=[*pass_ppcs_modeladm]
+wedpr.mybatis.username=
+wedpr.mybatis.password=
+
+wedpr.mybatis.driverClassName=com.mysql.cj.jdbc.Driver
+
+wedpr.mybatis.mapperLocations=classpath*:mapper/*Mapper.xml
+wedpr.mybatis.BasePackage=com.webank.wedpr.components.meta.resource.follower.dao,com.webank.wedpr.components.meta.sys.config.dao,com.webank.wedpr.components.project.dao,com.webank.wedpr.components.meta.setting.template.dao,com.webank.wedpr.components.sync.dao,com.webank.wedpr.components.authorization.dao,com.webank.wedpr.components.dataset.mapper,com.webank.wedpr.components.user.mapper,com.webank.wedpr.components.meta.agency.dao
diff --git a/wedpr-admin/db/wedpr_admin_ddl.sql b/wedpr-admin/db/wedpr_admin_ddl.sql
new file mode 100644
index 00000000..e8520531
--- /dev/null
+++ b/wedpr-admin/db/wedpr_admin_ddl.sql
@@ -0,0 +1,200 @@
+-- 创建机构表
+CREATE TABLE IF NOT EXISTS wedpr_agency (
+ agency_no VARCHAR(64) NOT NULL comment "机构编号",
+ agency_name VARCHAR(64) NOT NULL comment "机构名",
+ `desc` text NOT NULL comment "机构描述",
+ agency_contact VARCHAR(64) NOT NULL comment "机构联系人",
+ contact_phone VARCHAR(64) NOT NULL comment "联系电话",
+ gateway_endpoint VARCHAR(64) NOT NULL comment "网关地址",
+ agency_status TINYINT DEFAULT 0 NOT NULL comment "机构状态(0:启用,1:禁用)",
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ PRIMARY KEY (agency_no),
+ INDEX idx_agency_name (agency_name)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+
+-- 创建机构用户表
+CREATE TABLE IF NOT EXISTS wedpr_agency_user (
+ agency_no VARCHAR(64) NOT NULL comment "机构编号",
+ user_count INT DEFAULT 0 comment "机构用户数",
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ PRIMARY KEY (agency_no)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+-- 创建机构证书表
+CREATE TABLE IF NOT EXISTS wedpr_cert (
+ cert_id VARCHAR(64) NOT NULL comment "证书id",
+ agency_no VARCHAR(64) NOT NULL comment "机构编号",
+ agency_name VARCHAR(64) NOT NULL comment "机构名",
+ csr_file_text text NOT NULL comment "机构证书请求文件内容",
+ cert_file_text text NOT NULL comment "机构证书文件内容",
+ expire_time DATETIME NOT NULL comment "过期时间",
+ cert_status TINYINT DEFAULT 0 NOT NULL comment "证书状态(0:无证书,1:有效,2:过期,3:禁用)",
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ PRIMARY KEY (cert_id),
+ INDEX idx_agency_name (agency_name),
+ INDEX idx_cert_status (cert_status)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+CREATE TABLE if not exists `wedpr_dataset` (
+ `dataset_id` VARCHAR(64) NOT NULL COMMENT '数据集id',
+ `dataset_title` VARCHAR(1024) NOT NULL COMMENT '数据集标题',
+ `dataset_label` VARCHAR(1024) NOT NULL COMMENT '数据集标签',
+ `dataset_desc` TEXT NOT NULL COMMENT '数据集描述',
+ `dataset_fields` TEXT COMMENT '数据源字段以及预览信息',
+ `dataset_version_hash` VARCHAR(64) DEFAULT '' COMMENT '数据集hash',
+ `dataset_data_size` bigint DEFAULT 0 COMMENT '数据集大小',
+ `dataset_record_count` bigint DEFAULT 0 COMMENT '数据集记录数目',
+ `dataset_column_count` int DEFAULT 0 COMMENT '数据集列数目',
+ `dataset_storage_type` VARCHAR(255) DEFAULT '' COMMENT '数据集存储类型',
+ `dataset_storage_path` VARCHAR(1024) DEFAULT '' COMMENT '数据集存储路径',
+ `owner_agency_id` VARCHAR(255) NOT NULL COMMENT '数据集所属机构id',
+ `owner_agency_name` VARCHAR(255) NOT NULL COMMENT '数据集所属机构名称',
+ `owner_user_id` VARCHAR(1024) NOT NULL COMMENT '数据集所属用户名id',
+ `owner_user_name` VARCHAR(1024) NOT NULL COMMENT '数据集所属用户名',
+ `data_source_type` VARCHAR(255) NOT NULL COMMENT '数据源类型 : CSV、DB、XLSX、FPS、HDFS、HIVE',
+ `data_source_meta` TEXT NOT NULL COMMENT '数据源参数信息,JSON字符串',
+ `visibility` int(8) NOT NULL COMMENT '数据集可见性, 0: 私有,1: 公开可见',
+ `visibility_details` TEXT NOT NULL COMMENT '数据源可见范围描述, visibility 为1时有效',
+ `status` tinyint(4) NOT NULL COMMENT '数据集状态, 0: 有效,其他无效',
+ `status_desc` VARCHAR(1024) NOT NULL COMMENT '数据集状态描述',
+ `create_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `update_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`dataset_id`),
+ INDEX dataset_title_index (`dataset_title`(128)),
+ INDEX owner_agency_id_index (`owner_agency_id`),
+ INDEX owner_user_name_index (`owner_user_name`(128)),
+ INDEX create_at_index (`create_at`),
+ INDEX update_at_index (`update_at`)
+)ENGINE='InnoDB' DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_bin' ROW_FORMAT=DYNAMIC COMMENT '数据集记录表';
+
+create table if not exists `wedpr_project_table`(
+ `id` varchar(64) not null comment "项目ID",
+ `name` varchar(1024) not null comment "项目名称",
+ `desc` varchar(1024) not null comment "项目描述",
+ `owner` varchar(255) not null comment "项目属主",
+ `owner_agency` varchar(255) not null comment "项目所属机构",
+ `project_type` varchar(255) not null comment "项目类型(Export/Wizard)",
+ `label` varchar(1024) comment "项目标签",
+ `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP comment "项目创建时间",
+ `last_update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment "项目更新时间",
+ primary key (`id`),
+ unique index name_index(`name`(128)),
+ index owner_index(`owner`(128), `owner_agency`(128)),
+ index project_type_index(`project_type`(128)),
+ index label_index(`label`(128))
+)ENGINE=InnoDB default charset=utf8mb4 default collate=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+create table if not exists `wedpr_job_table`(
+ `id` varchar(64) not null comment "任务ID",
+ `name` varchar(1024) comment "任务名称",
+ `project_name` varchar(1024) comment "任务所属项目",
+ `owner` varchar(255) not null comment "任务发起人",
+ `owner_agency` varchar(255) not null comment "任务发起机构",
+ `job_type` varchar(255) not null comment "任务类型",
+ `parties` text comment "任务相关机构信息(json)",
+ `param` longtext comment "任务参数(json)",
+ `status` varchar(255) comment "任务状态",
+ `job_result` longtext comment "任务执行结果(json)",
+ `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP comment "任务创建时间",
+ `last_update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment "任务更新时间",
+ primary key(`id`),
+ index name_index(`name`(128)),
+ index owner_index(`owner`(128)),
+ index owner_agency_index(`owner_agency`(128)),
+ index project_index(`project_name`(128)),
+ index status_index(`status`(128))
+)ENGINE=InnoDB default charset=utf8mb4 default collate=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+-- 创建用户组表
+CREATE TABLE IF NOT EXISTS wedpr_group (
+ group_id VARCHAR(64) NOT NULL,
+ group_name VARCHAR(64) NOT NULL,
+ admin_name VARCHAR(64) NOT NULL DEFAULT '',
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ status TINYINT DEFAULT 0,
+ PRIMARY KEY (group_id),
+ INDEX idx_group_name (group_name),
+ INDEX idx_admin_name (admin_name)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+-- 创建用户组详情表
+CREATE TABLE IF NOT EXISTS wedpr_group_detail (
+ group_id VARCHAR(64) NOT NULL,
+ username VARCHAR(128) NOT NULL,
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ status TINYINT DEFAULT 0,
+ PRIMARY KEY (group_id, username),
+ INDEX idx_username (username)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+-- 创建用户表
+CREATE TABLE IF NOT EXISTS wedpr_user (
+ username VARCHAR(128) NOT NULL,
+ email VARCHAR(128),
+ password VARCHAR(256),
+ phone VARCHAR(64),
+ try_count int(10),
+ allowed_timestamp BIGINT(20),
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ status TINYINT DEFAULT 0,
+ PRIMARY KEY (username),
+ INDEX idx_email (email),
+ INDEX idx_phone (phone)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+-- 创建用户角色表
+CREATE TABLE IF NOT EXISTS wedpr_user_role (
+ username VARCHAR(128) NOT NULL,
+ role_id VARCHAR(64) NOT NULL,
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ PRIMARY KEY (username, role_id),
+ INDEX idx_role_id (role_id)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+-- 创建角色权限表
+CREATE TABLE IF NOT EXISTS wedpr_role_permission (
+ role_id VARCHAR(64) NOT NULL,
+ role_name VARCHAR(64) NOT NULL,
+ permission_id VARCHAR(64) NOT NULL,
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ PRIMARY KEY (role_id, permission_id),
+ INDEX idx_role_name (role_name ),
+ INDEX idx_permission_id (permission_id)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+
+-- 创建权限表
+CREATE TABLE IF NOT EXISTS wedpr_permission (
+ permission_id VARCHAR(64) NOT NULL,
+ permission_name VARCHAR(128) NOT NULL,
+ permission_content TEXT NOT NULL,
+ create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ create_by VARCHAR(20) NOT NULL DEFAULT '',
+ update_by VARCHAR(20) NOT NULL DEFAULT '',
+ PRIMARY KEY (permission_id)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
diff --git a/wedpr-admin/db/wedpr_admin_dml.sql b/wedpr-admin/db/wedpr_admin_dml.sql
new file mode 100644
index 00000000..6fdb2d7a
--- /dev/null
+++ b/wedpr-admin/db/wedpr_admin_dml.sql
@@ -0,0 +1,5 @@
+insert into wedpr_group (group_id, group_name, admin_name, status) values('1000000000000000', '初始用户组', 'admin', 0);
+insert into wedpr_group_detail (group_id, username, status) values('1000000000000000', 'admin', 0);
+insert into wedpr_user (username, password, status) values('admin', '{bcrypt}$2a$10$XuiuKLg23kxtC/ldvYN0/evt0Y3aoBC9iV29srhIBMMDORzCQiYA.', 0);
+insert into wedpr_user_role(username, role_id) values ('admin', '10');
+insert into wedpr_role_permission (role_id, role_name, permission_id) values ('10', 'admin_user', '1')
\ No newline at end of file
diff --git a/wedpr-admin/src/main/java/com/webank/wedpr/WedprAdminApplication.java b/wedpr-admin/src/main/java/com/webank/wedpr/WedprAdminApplication.java
new file mode 100644
index 00000000..00b4f1aa
--- /dev/null
+++ b/wedpr-admin/src/main/java/com/webank/wedpr/WedprAdminApplication.java
@@ -0,0 +1,20 @@
+package com.webank.wedpr;
+
+import com.webank.wedpr.components.initializer.WeDPRApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@SpringBootApplication
+@ComponentScan(basePackages = {"com.webank"})
+public class WedprAdminApplication {
+
+ public static void main(String[] args) throws Exception {
+ long startT = System.currentTimeMillis();
+ WeDPRApplication.main(args, "WeDPR-ADMIN");
+ System.out.println(
+ "WeDPR-ADMIN: start WedprAdminApplication success, timecost: "
+ + (System.currentTimeMillis() - startT)
+ + " ms.");
+ System.out.println("Swagger URL(Dev Mode): http://localhost:6850/swagger-ui/index.html");
+ }
+}
diff --git a/wedpr-components/security/src/main/java/com/webank/wedpr/components/security/config/JwtLoginFilter.java b/wedpr-components/security/src/main/java/com/webank/wedpr/components/security/config/JwtLoginFilter.java
index 2bccaab2..736cef55 100644
--- a/wedpr-components/security/src/main/java/com/webank/wedpr/components/security/config/JwtLoginFilter.java
+++ b/wedpr-components/security/src/main/java/com/webank/wedpr/components/security/config/JwtLoginFilter.java
@@ -51,22 +51,25 @@ public class JwtLoginFilter extends UsernamePasswordAuthenticationFilter {
private final WedprGroupDetailService wedprGroupDetailService;
private final WedprGroupService wedprGroupService;
private final WedprUserService wedprUserService;
+ private final String loginUrl;
public JwtLoginFilter(
AuthenticationManager authenticationManager,
UserJwtConfig userJwtConfig,
WedprGroupDetailService wedprGroupDetailService,
WedprGroupService wedprGroupService,
- WedprUserService wedprUserService) {
- super.setFilterProcessesUrl(Constant.LOGIN_URL);
+ WedprUserService wedprUserService,
+ String loginUrl) {
+ super.setFilterProcessesUrl(loginUrl);
this.authenticationManager = authenticationManager;
this.userJwtConfig = userJwtConfig;
this.wedprGroupDetailService = wedprGroupDetailService;
this.wedprGroupService = wedprGroupService;
this.wedprUserService = wedprUserService;
+ this.loginUrl = loginUrl;
}
- String getBodyString(HttpServletRequest request) throws Exception {
+ String getRequestBodyString(HttpServletRequest request) throws Exception {
BufferedReader br = request.getReader();
String tmp;
StringBuilder ret = new StringBuilder();
@@ -83,12 +86,12 @@ public Authentication attemptAuthentication(
throws AuthenticationException {
String username = null;
try {
- String requestParams = getBodyString(request);
+ String requestParams = getRequestBodyString(request);
LoginRequest loginRequest = objectMapper.readValue(requestParams, LoginRequest.class);
username = loginRequest.getUsername();
- // 验证普通用户登录request
+ // 检查登录请求
wedprUserService.checkWedprUserLoginReturn(loginRequest, userJwtConfig);
- // 验证密码
+ // 解密前端加密传输过来的密码,给到security验证
String password =
PasswordHelper.decryptPassword(
loginRequest.getPassword(), userJwtConfig.getPrivateKey());
diff --git a/wedpr-components/security/src/main/java/com/webank/wedpr/components/security/config/WebSecurityConfig.java b/wedpr-components/security/src/main/java/com/webank/wedpr/components/security/config/WebSecurityConfig.java
index 07a3da24..05157b67 100644
--- a/wedpr-components/security/src/main/java/com/webank/wedpr/components/security/config/WebSecurityConfig.java
+++ b/wedpr-components/security/src/main/java/com/webank/wedpr/components/security/config/WebSecurityConfig.java
@@ -6,9 +6,11 @@
import com.webank.wedpr.components.user.service.WedprGroupService;
import com.webank.wedpr.components.user.service.WedprUserRoleService;
import com.webank.wedpr.components.user.service.WedprUserService;
+import com.webank.wedpr.core.protocol.ServerTypeEnum;
import com.webank.wedpr.core.utils.Constant;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
@@ -39,6 +41,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired private LoadingCache loadingCache;
+ @Value("${server.type:site_end}")
+ private String serverType;
+
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
@@ -80,13 +85,15 @@ public void configure(WebSecurity web) throws Exception {
@Override
protected void configure(HttpSecurity http) throws Exception {
+ String loginUrl = getLoginUrl(serverType);
JwtLoginFilter jwtLoginFilter =
new JwtLoginFilter(
authenticationManager,
userJwtConfig,
wedprGroupDetailService,
wedprGroupService,
- wedprUserService);
+ wedprUserService,
+ loginUrl);
JwtAuthenticationFilter jwtAuthenticationFilter =
new JwtAuthenticationFilter(
authenticationManager, userJwtConfig, wedprUserService, loadingCache);
@@ -103,11 +110,19 @@ protected void configure(HttpSecurity http) throws Exception {
.sameOrigin()
.and()
.formLogin()
- .loginProcessingUrl(Constant.LOGIN_URL)
+ .loginProcessingUrl(loginUrl)
.and()
.addFilter(jwtLoginFilter)
.addFilter(jwtAuthenticationFilter)
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
+
+ public static String getLoginUrl(String serverType) {
+ String loginUrl = Constant.SITE_END_LOGIN_URL;
+ if (ServerTypeEnum.ADMIN_END.getName().equals(serverType)) {
+ loginUrl = Constant.ADMIN_END_LOGIN_URL;
+ }
+ return loginUrl;
+ }
}
diff --git a/wedpr-core/protocol/src/main/java/com/webank/wedpr/core/protocol/ServerTypeEnum.java b/wedpr-core/protocol/src/main/java/com/webank/wedpr/core/protocol/ServerTypeEnum.java
new file mode 100644
index 00000000..b5674f61
--- /dev/null
+++ b/wedpr-core/protocol/src/main/java/com/webank/wedpr/core/protocol/ServerTypeEnum.java
@@ -0,0 +1,17 @@
+package com.webank.wedpr.core.protocol;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
+public enum ServerTypeEnum {
+ /** 站点端 */
+ SITE_END("site_end", "站点端"),
+
+ /** 管理端 */
+ ADMIN_END("admin_end", "管理端");
+
+ private String name;
+ private String cnName;
+}
diff --git a/wedpr-core/protocol/src/main/java/com/webank/wedpr/core/protocol/UserRoleEnum.java b/wedpr-core/protocol/src/main/java/com/webank/wedpr/core/protocol/UserRoleEnum.java
index 103139a7..c7f68baa 100644
--- a/wedpr-core/protocol/src/main/java/com/webank/wedpr/core/protocol/UserRoleEnum.java
+++ b/wedpr-core/protocol/src/main/java/com/webank/wedpr/core/protocol/UserRoleEnum.java
@@ -6,6 +6,10 @@
@AllArgsConstructor
@Getter
public enum UserRoleEnum {
+
+ /** 管理端管理用户 */
+ AGENCY_ADMIN("10", "agency_admin"),
+
/** 机构用户 */
ADMIN_ROLE("1", "admin_user"),
diff --git a/wedpr-core/utils/src/main/java/com/webank/wedpr/core/utils/Constant.java b/wedpr-core/utils/src/main/java/com/webank/wedpr/core/utils/Constant.java
index 636a06cd..e13af54b 100644
--- a/wedpr-core/utils/src/main/java/com/webank/wedpr/core/utils/Constant.java
+++ b/wedpr-core/utils/src/main/java/com/webank/wedpr/core/utils/Constant.java
@@ -43,7 +43,8 @@ public class Constant {
/** @Fields DEFAULT_PAGE_SIZE:分页的每页记录数 */
public static final int DEFAULT_PAGE_SIZE = 5;
- public static final String LOGIN_URL = WEDPR_API_PREFIX + "/login";
+ public static final String SITE_END_LOGIN_URL = WEDPR_API_PREFIX + "/login";
+ public static final String ADMIN_END_LOGIN_URL = WEDPR_API_PREFIX + "/admin/login";
public static final String REGISTER_URL = WEDPR_API_PREFIX + "/register";
public static final String USER_PUBLICKEY_URL = WEDPR_API_PREFIX + "/pub";
public static final String IMAGE_CODE_URL = WEDPR_API_PREFIX + "/image-code";