Skip to content

Commit e130344

Browse files
feature(alldatadc): ElAdmin 认证问题修复 && 支持3节点分布式部署微服务 && 新增README部署文档 && 修改部署SQL脚本只使用单个数据库Eladmin
1 parent b13d63a commit e130344

File tree

596 files changed

+42706
-63480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

596 files changed

+42706
-63480
lines changed

oneHub/eladmin-versions/eladmin-2.6/.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
*/target/*
55
*/*.iml
66
/.gradle/
7-
/application.pid
8-
*.yml
7+
/application.pid

oneHub/eladmin-versions/eladmin-2.6/README.md

+25-51
Original file line numberDiff line numberDiff line change
@@ -157,63 +157,35 @@
157157
>
158158
> 上传服务器解压
159159
>
160-
#### 5、部署微服务:install/alldata_dev/alldata_start.md
161-
>
162-
| 16gmaster | port | ip |
163-
|--------------------------------| ---- | -------------- |
164-
| eladmin-system | 8613 | 16gmaster |
165-
| datax-config | 8611 | 16gmaster |
166-
| data-market-service | 8822 | 16gmaster |
167-
| datax-service-data-integration | 8824 | 16gmaster |
168-
| data-metadata-service | 8820 | 16gmaster |
169-
170-
| 16gslave | port | ip |
171-
|-------------------------------| ---- | -------------- |
172-
| datax-eureka | 8610 | 16gslave |
173-
| datax-gateway | 8612 | 16gslave |
174-
| datax-service-workflow | 8814 | 16gslave |
175-
| data-metadata-service-console | 8821 | 16gslave |
176-
| datax-service-data-mapping | 8823 | 16gslave |
177-
| data-masterdata-service | 8828 | 16gslave |
178-
| data-quality-service | 8826 | 16gslave |
179-
180-
| 16gdata | port | ip |
181-
|-----------------------| ---- | -------------- |
182-
| data-standard-service | 8825 | 16gdata |
183-
| data-visual-service | 8827 | 16gdata |
184-
| email-service | 8812 | 16gdata |
185-
| file-service | 8811 | 16gdata |
186-
| quartz-service | 8813 | 16gdata |
187-
| system-service | 8810 | 16gdata |
188-
| datax-tool-monitor | 8711 | 16gdata |
189-
190-
191-
#### 6、启动顺序
192-
193-
> 1、启动eureka
194-
>
195-
> 2、启动config
196-
>
197-
> 3、启动gateway
198-
>
199-
> 4、启动masterdata
200-
>
201-
> 5、启动metadata
202-
>
203-
> 6、启动其他Jar
160+
#### 5、部署微服务: 进入不同的目录启动相关服务
204161
>
205-
> 用户名:admin 密码:123456
162+
> 5.1 必须启动、并且顺序启动
163+
>
164+
> eureka->config->gateway
165+
>
166+
> 5.2 按需启动`cd install/16gmaster`
206167
>
168+
> 譬如启动元数据管理
207169
>
208-
#### 7、部署`Eladmin`:
170+
> sh `install/16gmaster/data-metadata-service.sh`
209171
>
210-
> 7.1 启动`Eladmin`后端
172+
> tail -100f `install/16gmaster/data-metadata-service.log`
211173
>
212-
> nohup java -jar -Xms128m -Xmx2048m -XX:PermSize=128M -XX:MaxPermSize=256M -XX:+UseG1GC -XX:MaxGCPauseMillis=20
174+
> 5.2 按需启动`cd install/16gdata`
213175
>
214-
> -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -XX:MaxInlineLevel=15 /mnt/poc/eladmin/deploy/eladmin-system-2.6.jar &
176+
> 按需启动相关服务
215177
>
216-
> 7.2 部署`Eladmin`前端
178+
> 5.3 按需启动`cd install/16gslave`
179+
>
180+
> 按需启动相关服务
181+
>
182+
>
183+
184+
#### 6、部署`Eladmin`:
185+
>
186+
> 6.1 启动`sh install/16gmaster/eladmin-system.sh`
187+
>
188+
> 6.2 部署`Eladmin`前端
217189
>
218190
> source /etc/profile
219191
>
@@ -223,6 +195,8 @@
223195
>
224196
> nohup npm run dev &
225197
>
226-
> 7.3 访问`Eladmin`页面
198+
> 6.3 访问`Eladmin`页面
227199
>
228200
> curl http://localhost:8013
201+
>
202+
> 用户名:admin 密码:123456
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>eladmin</artifactId>
7+
<groupId>com.platform</groupId>
8+
<version>2.6</version>
9+
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
<version>2.6</version>
13+
<artifactId>datax-auth</artifactId>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.springframework.boot</groupId>
18+
<artifactId>spring-boot-starter-web</artifactId>
19+
<exclusions>
20+
<exclusion>
21+
<artifactId>spring-boot-starter-tomcat</artifactId>
22+
<groupId>org.springframework.boot</groupId>
23+
</exclusion>
24+
</exclusions>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-undertow</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework.cloud</groupId>
32+
<artifactId>spring-cloud-starter-config</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>com.platform</groupId>
36+
<artifactId>datax-common-core</artifactId>
37+
<version>2.6</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>com.platform</groupId>
41+
<artifactId>datax-common-mybatis</artifactId>
42+
<version>2.6</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>com.platform</groupId>
46+
<artifactId>datax-common-security</artifactId>
47+
<version>2.6</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.platform</groupId>
51+
<artifactId>datax-common-redis</artifactId>
52+
<version>2.6</version>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>com.platform</groupId>
57+
<artifactId>eladmin-service-api</artifactId>
58+
<version>2.6</version>
59+
</dependency>
60+
61+
<!--Spring boot Redis-->
62+
<dependency>
63+
<groupId>org.springframework.boot</groupId>
64+
<artifactId>spring-boot-starter-data-redis</artifactId>
65+
</dependency>
66+
</dependencies>
67+
68+
<build>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.springframework.boot</groupId>
72+
<artifactId>spring-boot-maven-plugin</artifactId>
73+
</plugin>
74+
</plugins>
75+
</build>
76+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package cn.datax.auth;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
6+
import org.springframework.cloud.client.SpringCloudApplication;
7+
import org.springframework.cloud.openfeign.EnableFeignClients;
8+
9+
@EnableFeignClients(basePackages = {"cn.datax.service.system.api.feign"})
10+
@SpringCloudApplication
11+
public class DataxAuthApplication {
12+
13+
public static void main(String[] args) {
14+
SpringApplication.run(DataxAuthApplication.class, args);
15+
}
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
package cn.datax.auth.config;
2+
3+
import cn.datax.auth.service.DataUserDetailService;
4+
import cn.datax.auth.translator.DataWebResponseExceptionTranslator;
5+
import cn.datax.common.core.DataConstant;
6+
import cn.datax.common.core.DataUser;
7+
8+
import cn.datax.common.security.utils.RedisTokenStore;
9+
import cn.hutool.core.collection.CollUtil;
10+
import cn.hutool.core.util.StrUtil;
11+
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.springframework.context.annotation.Bean;
13+
import org.springframework.context.annotation.Configuration;
14+
import org.springframework.data.redis.connection.RedisConnectionFactory;
15+
import org.springframework.security.authentication.AuthenticationManager;
16+
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
17+
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
18+
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
19+
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
20+
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
21+
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
22+
import org.springframework.security.oauth2.provider.ClientDetailsService;
23+
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
24+
import org.springframework.security.oauth2.provider.token.*;
25+
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
26+
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
27+
28+
import javax.sql.DataSource;
29+
import java.util.HashMap;
30+
import java.util.Map;
31+
32+
@Configuration
33+
@EnableAuthorizationServer
34+
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
35+
36+
@Autowired
37+
private DataSource dataSource;
38+
39+
@Autowired
40+
private AuthenticationManager authenticationManager;
41+
42+
@Autowired
43+
private DataUserDetailService userDetailService;
44+
45+
@Autowired
46+
private RedisConnectionFactory redisConnectionFactory;
47+
48+
@Autowired
49+
private DataWebResponseExceptionTranslator exceptionTranslator;
50+
51+
52+
53+
/**
54+
* 配置客户端详情服务
55+
* @param clients
56+
* @throws Exception
57+
*/
58+
@Override
59+
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
60+
// 默认数据库的配置
61+
// datax:123456
62+
// normal-app:normal-app
63+
// trusted-app:trusted-app
64+
clients.jdbc(dataSource).clients(clientDetails());
65+
}
66+
67+
/**
68+
* 用来配置令牌端点(Token Endpoint)的安全约束.
69+
* @param security
70+
* @throws Exception
71+
*/
72+
@Override
73+
public void configure(AuthorizationServerSecurityConfigurer security) {
74+
security.tokenKeyAccess("permitAll()")
75+
.checkTokenAccess("isAuthenticated()")
76+
.allowFormAuthenticationForClients();
77+
}
78+
79+
/**
80+
* 用来配置授权(authorization)以及令牌(token)的访问端点和令牌服务(token services)
81+
* @param endpoints
82+
* @throws Exception
83+
*/
84+
@Override
85+
public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
86+
endpoints.tokenStore(tokenStore())
87+
.tokenServices(tokenServices())
88+
.userDetailsService(userDetailService)
89+
.authenticationManager(authenticationManager)
90+
.exceptionTranslator(exceptionTranslator);
91+
}
92+
93+
@Bean
94+
public ClientDetailsService clientDetails() {
95+
return new JdbcClientDetailsService(dataSource);
96+
}
97+
98+
@Bean
99+
public TokenStore tokenStore(){
100+
return new JwtTokenStore(accessTokenConverter());
101+
}
102+
103+
@Bean
104+
public JwtAccessTokenConverter accessTokenConverter() {
105+
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
106+
converter.setSigningKey("123");
107+
return converter;
108+
}
109+
110+
@Bean
111+
public DefaultTokenServices tokenServices(){
112+
DefaultTokenServices tokenServices = new DefaultTokenServices();
113+
tokenServices.setTokenStore(tokenStore());
114+
tokenServices.setSupportRefreshToken(true);
115+
tokenServices.setClientDetailsService(clientDetails());
116+
tokenServices.setTokenEnhancer(tokenEnhancer());
117+
// // token有效期自定义设置,默认12小时 设置为24小时86400
118+
// tokenServices.setAccessTokenValiditySeconds(60 * 60 * 24 * 1);
119+
// // refresh_token默认30天 设置为7天604800
120+
// tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 24 * 7);
121+
return tokenServices;
122+
}
123+
124+
@Bean
125+
public TokenEnhancer tokenEnhancer() {
126+
return (accessToken, authentication) -> {
127+
final Map<String, Object> additionalInfo = new HashMap<>();
128+
DataUser user = (DataUser) authentication.getUserAuthentication().getPrincipal();
129+
additionalInfo.put(DataConstant.UserAdditionalInfo.LICENSE.getKey(), DataConstant.UserAdditionalInfo.LICENSE.getVal());
130+
additionalInfo.put(DataConstant.UserAdditionalInfo.USERID.getKey(), user.getId());
131+
additionalInfo.put(DataConstant.UserAdditionalInfo.USERNAME.getKey(), user.getUsername());
132+
additionalInfo.put(DataConstant.UserAdditionalInfo.NICKNAME.getKey(), user.getNickname());
133+
134+
if (StrUtil.isNotBlank(user.getDept())){
135+
additionalInfo.put(DataConstant.UserAdditionalInfo.DEPT.getKey(), user.getDept());
136+
}
137+
if (CollUtil.isNotEmpty(user.getRoles())){
138+
additionalInfo.put(DataConstant.UserAdditionalInfo.ROLE.getKey(), user.getRoles());
139+
}
140+
if (CollUtil.isNotEmpty(user.getPosts())){
141+
additionalInfo.put(DataConstant.UserAdditionalInfo.POST.getKey(), user.getPosts());
142+
}
143+
((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
144+
return accessToken;
145+
};
146+
}
147+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
package com.platform.dts.config;
1+
package cn.datax.auth.config;
2+
23

3-
import cn.datax.common.security.handler.DataAccessDeniedHandler;
4-
import cn.datax.common.security.handler.DataAuthExceptionEntryPoint;
54
import org.springframework.beans.factory.annotation.Autowired;
65
import org.springframework.context.annotation.Configuration;
76
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -23,11 +22,7 @@
2322
@EnableResourceServer
2423
public class DataResourceServerConfig extends ResourceServerConfigurerAdapter {
2524

26-
@Autowired
27-
private DataAccessDeniedHandler accessDeniedHandler;
2825

29-
@Autowired
30-
private DataAuthExceptionEntryPoint exceptionEntryPoint;
3126

3227
@Override
3328
public void configure(HttpSecurity http) throws Exception {

0 commit comments

Comments
 (0)