Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄营
datax-cloud
Commits
7bef1cf6
Commit
7bef1cf6
authored
Nov 20, 2019
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
d3cbdf30
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
52 deletions
+23
-52
AuthorizationServerConfig.java
.../java/cn/datax/auth/config/AuthorizationServerConfig.java
+4
-4
DataUserDetailService.java
...ain/java/cn/datax/auth/service/DataUserDetailService.java
+3
-2
DataConstant.java
...core/src/main/java/cn/datax/common/core/DataConstant.java
+0
-30
DataFeignRequestInterceptor.java
...ax/common/security/feign/DataFeignRequestInterceptor.java
+3
-3
DataServerProtectInterceptor.java
...on/security/interceptor/DataServerProtectInterceptor.java
+5
-5
DataUserAuthenticationConverter.java
...ommon/security/utils/DataUserAuthenticationConverter.java
+3
-3
application-dev.yml
datax-config/src/main/resources/config/application-dev.yml
+2
-2
DataGatewayRequestFilter.java
...ava/cn/datax/gateway/filter/DataGatewayRequestFilter.java
+2
-2
UserServiceImpl.java
...cn/datax/service/system/service/impl/UserServiceImpl.java
+1
-1
No files found.
datax-auth/src/main/java/cn/datax/auth/config/AuthorizationServerConfig.java
View file @
7bef1cf6
...
...
@@ -118,10 +118,10 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
return
(
accessToken
,
authentication
)
->
{
final
Map
<
String
,
Object
>
additionalInfo
=
new
HashMap
<>();
DataUser
user
=
(
DataUser
)
authentication
.
getUserAuthentication
().
getPrincipal
();
additionalInfo
.
put
(
DataConstant
.
DETAILS_SECURITY_LICENSE
,
"datax"
);
additionalInfo
.
put
(
DataConstant
.
DETAILS_SECURITY_USER_ID
,
user
.
getId
());
additionalInfo
.
put
(
DataConstant
.
DETAILS_SECURITY_USERNAME
,
user
.
getUsername
());
additionalInfo
.
put
(
DataConstant
.
DETAILS_SECURITY_NICKNAME
,
user
.
getNickname
());
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
LICENSE
.
getKey
()
,
"datax"
);
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
USERID
.
getKey
()
,
user
.
getId
());
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
USERNAME
.
getKey
()
,
user
.
getUsername
());
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
NICKNAME
.
getKey
()
,
user
.
getNickname
());
((
DefaultOAuth2AccessToken
)
accessToken
).
setAdditionalInformation
(
additionalInfo
);
return
accessToken
;
};
...
...
datax-auth/src/main/java/cn/datax/auth/service/DataUserDetailService.java
View file @
7bef1cf6
...
...
@@ -54,10 +54,11 @@ public class DataUserDetailService implements UserDetailsService {
UserVo
userVo
=
userInfo
.
getUserVo
();
List
<
RoleVo
>
roles
=
userVo
.
getRoles
();
if
(
CollUtil
.
isNotEmpty
(
roles
))
{
roles
.
stream
().
filter
(
roleVo
->
DataConstant
.
TRUE
==
roleVo
.
getStatus
()
&&
StrUtil
.
isNotBlank
(
roleVo
.
getRoleCode
())).
forEach
(
roleVo
->
authsSet
.
add
(
DataConstant
.
ROLE
+
roleVo
.
getRoleCode
()));
roles
.
stream
().
filter
(
roleVo
->
DataConstant
.
EnableState
.
ENABLE
.
getKey
()
==
roleVo
.
getStatus
()
&&
StrUtil
.
isNotBlank
(
roleVo
.
getRoleCode
()))
.
forEach
(
roleVo
->
authsSet
.
add
(
DataConstant
.
Security
.
ROLEPREFIX
.
getVal
()
+
roleVo
.
getRoleCode
()));
}
if
(
CollUtil
.
isEmpty
(
authsSet
)){
authsSet
.
add
(
DataConstant
.
ROLE
+
"USER"
);
authsSet
.
add
(
DataConstant
.
Security
.
ROLEPREFIX
.
getVal
()
+
"USER"
);
}
Collection
<?
extends
GrantedAuthority
>
authorities
=
AuthorityUtils
.
createAuthorityList
(
authsSet
.
toArray
(
new
String
[
0
]));
...
...
datax-common/datax-common-core/src/main/java/cn/datax/common/core/DataConstant.java
View file @
7bef1cf6
...
...
@@ -105,34 +105,4 @@ public class DataConstant {
return
val
;
}
}
/**
* Gateway请求头TOKEN名称(不要有空格)
*/
public
static
final
String
GATEWAY_TOKEN_HEADER
=
"GatewayToken"
;
/**
* Gateway请求头TOKEN值
*/
public
static
final
String
GATEWAY_TOKEN_VALUE
=
"datax:gateway:123456"
;
/**
* OAUTH2 令牌类型
*/
public
static
final
String
OAUTH2_TOKEN_TYPE
=
"bearer "
;
public
static
String
ROLE
=
"ROLE_"
;
public
static
int
TRUE
=
1
;
public
static
int
FALSE
=
0
;
public
static
String
DETAILS_SECURITY_LICENSE
=
"license"
;
public
static
String
DETAILS_SECURITY_DATAX_USER
=
"datax_user"
;
public
static
String
DETAILS_SECURITY_USER_ID
=
"user_id"
;
public
static
String
DETAILS_SECURITY_USERNAME
=
"username"
;
public
static
String
DETAILS_SECURITY_NICKNAME
=
"nickname"
;
public
static
String
DETAILS_SECURITY_USER_DEPT
=
"user_dept"
;
public
static
String
DETAILS_SECURITY_USER_ROLE
=
"user_role"
;
public
static
String
DETAILS_SECURITY_USER_POST
=
"user_post"
;
}
datax-common/datax-common-security/src/main/java/cn/datax/common/security/feign/DataFeignRequestInterceptor.java
View file @
7bef1cf6
...
...
@@ -16,13 +16,13 @@ public class DataFeignRequestInterceptor {
public
RequestInterceptor
oauth2FeignRequestInterceptor
()
{
return
requestTemplate
->
{
// 请求头中添加 Gateway Token
String
zuulToken
=
new
String
(
Base64Utils
.
encode
(
DataConstant
.
GATEWAY_TOKEN_VALUE
.
getBytes
()));
requestTemplate
.
header
(
DataConstant
.
GATEWAY_TOKEN_HEADER
,
zuulToken
);
String
zuulToken
=
new
String
(
Base64Utils
.
encode
(
DataConstant
.
Security
.
TOKENVALUE
.
getVal
()
.
getBytes
()));
requestTemplate
.
header
(
DataConstant
.
Security
.
TOKENHEADER
.
getVal
()
,
zuulToken
);
// 请求头中添加原请求头中的 Token
Object
details
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getDetails
();
if
(
details
instanceof
OAuth2AuthenticationDetails
)
{
String
authorizationToken
=
((
OAuth2AuthenticationDetails
)
details
).
getTokenValue
();
requestTemplate
.
header
(
HttpHeaders
.
AUTHORIZATION
,
DataConstant
.
OAUTH2_TOKEN_TYPE
+
authorizationToken
);
requestTemplate
.
header
(
HttpHeaders
.
AUTHORIZATION
,
DataConstant
.
Security
.
TOKENTYPE
.
getVal
()
+
authorizationToken
);
}
};
}
...
...
datax-common/datax-common-security/src/main/java/cn/datax/common/security/interceptor/DataServerProtectInterceptor.java
View file @
7bef1cf6
...
...
@@ -16,11 +16,11 @@ public class DataServerProtectInterceptor implements HandlerInterceptor {
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
IOException
{
// 从请求头中获取
Zuul
Token
String
token
=
request
.
getHeader
(
DataConstant
.
GATEWAY_TOKEN_HEADER
);
String
zuulToken
=
new
String
(
Base64Utils
.
encode
(
DataConstant
.
GATEWAY_TOKEN_VALUE
.
getBytes
()));
// 校验
Zuul
Token的正确性
if
(
StrUtil
.
equals
(
zuul
Token
,
token
))
{
// 从请求头中获取Token
String
token
=
request
.
getHeader
(
DataConstant
.
Security
.
TOKENHEADER
.
getVal
()
);
String
gatewayToken
=
new
String
(
Base64Utils
.
encode
(
DataConstant
.
Security
.
TOKENVALUE
.
getVal
()
.
getBytes
()));
// 校验Token的正确性
if
(
StrUtil
.
equals
(
gateway
Token
,
token
))
{
return
true
;
}
else
{
ResponseUtil
.
makeResponse
(
...
...
datax-common/datax-common-security/src/main/java/cn/datax/common/security/utils/DataUserAuthenticationConverter.java
View file @
7bef1cf6
...
...
@@ -42,9 +42,9 @@ public class DataUserAuthenticationConverter implements UserAuthenticationConver
Object
principal
=
map
.
get
(
USERNAME
);
Collection
<?
extends
GrantedAuthority
>
authorities
=
this
.
getAuthorities
(
map
);
String
id
=
(
String
)
map
.
get
(
DataConstant
.
DETAILS_SECURITY_USER_ID
);
String
username
=
(
String
)
map
.
get
(
DataConstant
.
DETAILS_SECURITY_USERNAME
);
String
nickname
=
(
String
)
map
.
get
(
DataConstant
.
DETAILS_SECURITY_USERNAME
);
String
id
=
(
String
)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
USERID
.
getKey
()
);
String
username
=
(
String
)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
USERNAME
.
getKey
()
);
String
nickname
=
(
String
)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
NICKNAME
.
getKey
()
);
DataUser
user
=
new
DataUser
(
id
,
nickname
,
username
,
N_A
,
true
,
true
,
true
,
true
,
authorities
);
return
new
UsernamePasswordAuthenticationToken
(
user
,
N_A
,
authorities
);
...
...
datax-config/src/main/resources/config/application-dev.yml
View file @
7bef1cf6
...
...
@@ -36,8 +36,8 @@ feign:
client
:
config
:
default
:
connectTimeout
:
5
000
readTimeout
:
5
000
connectTimeout
:
10
000
readTimeout
:
10
000
compression
:
request
:
enabled
:
true
...
...
datax-gateway/src/main/java/cn/datax/gateway/filter/DataGatewayRequestFilter.java
View file @
7bef1cf6
...
...
@@ -31,9 +31,9 @@ public class DataGatewayRequestFilter implements GlobalFilter {
printLog
(
exchange
);
byte
[]
token
=
Base64Utils
.
encode
((
DataConstant
.
GATEWAY_TOKEN_VALUE
).
getBytes
());
byte
[]
token
=
Base64Utils
.
encode
((
DataConstant
.
Security
.
TOKENVALUE
.
getVal
()
).
getBytes
());
String
[]
headerValues
=
{
new
String
(
token
)};
ServerHttpRequest
build
=
request
.
mutate
().
header
(
DataConstant
.
GATEWAY_TOKEN_HEADER
,
headerValues
).
build
();
ServerHttpRequest
build
=
request
.
mutate
().
header
(
DataConstant
.
Security
.
TOKENHEADER
.
getVal
()
,
headerValues
).
build
();
ServerWebExchange
newExchange
=
exchange
.
mutate
().
request
(
build
).
build
();
return
chain
.
filter
(
newExchange
);
}
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/service/impl/UserServiceImpl.java
View file @
7bef1cf6
...
...
@@ -148,7 +148,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
if
(
CollUtil
.
isNotEmpty
(
userVo
.
getRoles
())){
Set
<
String
>
permissions
=
new
HashSet
<>();
List
<
String
>
roleIds
=
userVo
.
getRoles
().
stream
()
.
filter
(
roleVo
->
DataConstant
.
TRUE
==
roleVo
.
getStatus
())
.
filter
(
roleVo
->
DataConstant
.
EnableState
.
ENABLE
.
getKey
()
==
roleVo
.
getStatus
())
.
map
(
RoleVo:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
MenuEntity
>
menuEntitys
=
menuDao
.
selectMenuByRoleIds
(
roleIds
);
if
(
CollUtil
.
isNotEmpty
(
menuEntitys
)){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment