Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
long-tern-care-service
Project
Project
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
hubin
long-tern-care-service
Commits
361ab204
Commit
361ab204
authored
Mar 30, 2021
by
hubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除一些无用代码
parent
321ba575
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2 additions
and
144 deletions
+2
-144
pom.xml
auth-service/pom.xml
+0
-6
AuthorizationServerConfiguration.java
.../ism/gateway/config/AuthorizationServerConfiguration.java
+1
-46
EnterpriseWechatTokenGranter.java
...ay/config/tokenGranters/EnterpriseWechatTokenGranter.java
+0
-51
build.sh
build.sh
+1
-19
WechatConstants.java
.../main/java/com/hungraim/ism/constant/WechatConstants.java
+0
-19
SystemClientDetails.java
.../hungraim/ism/pojo/entity/system/SystemClientDetails.java
+0
-3
No files found.
auth-service/pom.xml
View file @
361ab204
...
@@ -59,12 +59,6 @@
...
@@ -59,12 +59,6 @@
<version>
0.0.1
</version>
<version>
0.0.1
</version>
</dependency>
</dependency>
<!--微信服务api-->
<dependency>
<groupId>
com.hungraim.ism
</groupId>
<artifactId>
wechat-api
</artifactId>
<version>
0.0.1
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
...
auth-service/src/main/java/com/hungraim/ism/gateway/config/AuthorizationServerConfiguration.java
View file @
361ab204
...
@@ -3,8 +3,6 @@ package com.hungraim.ism.gateway.config;
...
@@ -3,8 +3,6 @@ package com.hungraim.ism.gateway.config;
import
cn.hutool.http.HttpStatus
;
import
cn.hutool.http.HttpStatus
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.hungraim.ism.api.WechatFeignService
;
import
com.hungraim.ism.gateway.config.tokenGranters.EnterpriseWechatTokenGranter
;
import
com.hungraim.ism.pojo.vo.system.UserLoginInfoVO
;
import
com.hungraim.ism.pojo.vo.system.UserLoginInfoVO
;
import
com.hungraim.ism.service.UserDetailsServiceImpl
;
import
com.hungraim.ism.service.UserDetailsServiceImpl
;
import
com.hungraim.ism.util.Result
;
import
com.hungraim.ism.util.Result
;
...
@@ -59,14 +57,12 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu
...
@@ -59,14 +57,12 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu
private
final
AuthenticationManager
authenticationManager
;
private
final
AuthenticationManager
authenticationManager
;
private
final
UserDetailsServiceImpl
userDetailsService
;
private
final
UserDetailsServiceImpl
userDetailsService
;
private
final
DataSource
dataSource
;
private
final
DataSource
dataSource
;
private
final
WechatFeignService
wechatFeignService
;
@Autowired
@Autowired
public
AuthorizationServerConfiguration
(
AuthenticationManager
authenticationManager
,
DataSource
dataSource
,
UserDetailsServiceImpl
userDetailsService
,
WechatFeignService
wechatFeignService
)
{
public
AuthorizationServerConfiguration
(
AuthenticationManager
authenticationManager
,
DataSource
dataSource
,
UserDetailsServiceImpl
userDetailsService
)
{
this
.
authenticationManager
=
authenticationManager
;
this
.
authenticationManager
=
authenticationManager
;
this
.
dataSource
=
dataSource
;
this
.
dataSource
=
dataSource
;
this
.
userDetailsService
=
userDetailsService
;
this
.
userDetailsService
=
userDetailsService
;
this
.
wechatFeignService
=
wechatFeignService
;
}
}
...
@@ -100,7 +96,6 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu
...
@@ -100,7 +96,6 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu
.
accessTokenConverter
(
jwtAccessTokenConverter
())
.
accessTokenConverter
(
jwtAccessTokenConverter
())
.
tokenEnhancer
(
tokenEnhancerChain
)
.
tokenEnhancer
(
tokenEnhancerChain
)
.
userDetailsService
(
userDetailsService
)
.
userDetailsService
(
userDetailsService
)
.
tokenGranter
(
tokenGranter
(
endpoints
))
// refresh token有两种使用方式:重复使用(true)、非重复使用(false),默认为true
// refresh token有两种使用方式:重复使用(true)、非重复使用(false),默认为true
// 1 重复使用:access token过期刷新时, refresh token过期时间未改变,仍以初次生成的时间为准
// 1 重复使用:access token过期刷新时, refresh token过期时间未改变,仍以初次生成的时间为准
// 2 非重复使用:access token过期刷新时, refresh token过期时间延续,在refresh token有效期内刷新便永不失效达到无需再次登录的目的
// 2 非重复使用:access token过期刷新时, refresh token过期时间延续,在refresh token有效期内刷新便永不失效达到无需再次登录的目的
...
@@ -115,46 +110,6 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu
...
@@ -115,46 +110,6 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu
.
allowFormAuthenticationForClients
();
.
allowFormAuthenticationForClients
();
}
}
private
TokenGranter
tokenGranter
(
AuthorizationServerEndpointsConfigurer
endpoints
)
{
List
<
TokenGranter
>
list
=
new
ArrayList
<>();
// 这里配置密码模式
if
(
authenticationManager
!=
null
)
{
list
.
add
(
new
ResourceOwnerPasswordTokenGranter
(
authenticationManager
,
endpoints
.
getTokenServices
(),
endpoints
.
getClientDetailsService
(),
endpoints
.
getOAuth2RequestFactory
()));
}
//刷新token模式、
list
.
add
(
new
RefreshTokenGranter
(
endpoints
.
getTokenServices
(),
endpoints
.
getClientDetailsService
(),
endpoints
.
getOAuth2RequestFactory
()));
//授权码模式、
list
.
add
(
new
AuthorizationCodeTokenGranter
(
endpoints
.
getTokenServices
(),
endpoints
.
getAuthorizationCodeServices
(),
endpoints
.
getClientDetailsService
(),
endpoints
.
getOAuth2RequestFactory
()));
//、简化模式
list
.
add
(
new
ImplicitTokenGranter
(
endpoints
.
getTokenServices
(),
endpoints
.
getClientDetailsService
(),
endpoints
.
getOAuth2RequestFactory
()));
//客户端模式
list
.
add
(
new
ClientCredentialsTokenGranter
(
endpoints
.
getTokenServices
(),
endpoints
.
getClientDetailsService
(),
endpoints
.
getOAuth2RequestFactory
()));
list
.
add
(
new
EnterpriseWechatTokenGranter
(
endpoints
.
getTokenServices
(),
endpoints
.
getClientDetailsService
(),
endpoints
.
getOAuth2RequestFactory
(),
wechatFeignService
));
return
new
CompositeTokenGranter
(
list
);
}
/**
/**
...
...
auth-service/src/main/java/com/hungraim/ism/gateway/config/tokenGranters/EnterpriseWechatTokenGranter.java
deleted
100644 → 0
View file @
321ba575
package
com
.
hungraim
.
ism
.
gateway
.
config
.
tokenGranters
;
import
com.hungraim.ism.api.WechatFeignService
;
import
com.hungraim.ism.pojo.entity.system.SystemUser
;
import
com.hungraim.ism.pojo.vo.system.UserLoginInfoVO
;
import
com.hungraim.ism.util.Result
;
import
com.hungraim.ism.util.ResultCode
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.oauth2.common.exceptions.InvalidGrantException
;
import
org.springframework.security.oauth2.provider.*
;
import
org.springframework.security.oauth2.provider.token.AbstractTokenGranter
;
import
org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 自定义grant_type模式--企业微信认证
* @author hubin
*/
public
class
EnterpriseWechatTokenGranter
extends
AbstractTokenGranter
{
private
static
final
String
GRANT_TYPE
=
"enterpriseWechat"
;
private
final
WechatFeignService
wechatFeignService
;
public
EnterpriseWechatTokenGranter
(
AuthorizationServerTokenServices
tokenServices
,
ClientDetailsService
clientDetailsService
,
OAuth2RequestFactory
oAuth2RequestFactory
,
WechatFeignService
wechatFeignService
)
{
super
(
tokenServices
,
clientDetailsService
,
oAuth2RequestFactory
,
GRANT_TYPE
);
this
.
wechatFeignService
=
wechatFeignService
;
}
@SuppressWarnings
(
"AlibabaLowerCamelCaseVariableNaming"
)
@Override
protected
OAuth2Authentication
getOAuth2Authentication
(
ClientDetails
client
,
TokenRequest
tokenRequest
)
{
Map
<
String
,
String
>
parameters
=
new
LinkedHashMap
<>(
tokenRequest
.
getRequestParameters
());
String
code
=
parameters
.
get
(
"code"
);
//通过code去企业微信获取用户id 再组装成用户
Result
<
SystemUser
>
user
=
wechatFeignService
.
getUserInfoByCode
(
code
);
if
(
user
==
null
||
!
ResultCode
.
SUCCESS
.
getCode
().
equals
(
user
.
getCode
())){
throw
new
InvalidGrantException
(
user
.
getMsg
());
}
UserDetails
userDTO
=
new
UserLoginInfoVO
(
user
.
getData
());
Authentication
userAuth
=
new
UsernamePasswordAuthenticationToken
(
userDTO
,
null
,
userDTO
.
getAuthorities
());
return
new
OAuth2Authentication
(
getRequestFactory
().
createOAuth2Request
(
client
,
tokenRequest
),
userAuth
);
}
}
build.sh
View file @
361ab204
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
echo
'开始构建智能营销平台项目'
echo
'开始构建智能营销平台项目'
export
PATH
=
${
PATH
}
:/usr/local/maven/bin
export
PATH
=
${
PATH
}
:/usr/local/maven/bin
buildDeploys
=(
"common/common-core"
"common/common-mybatis"
"common/common-redis"
"system/system-api"
"wechat/wechat-api"
)
buildDeploys
=(
"common/common-core"
"common/common-mybatis"
"common/common-redis"
"system/system-api"
)
mvn clean
#清空历史数据
mvn clean
#清空历史数据
buildDeploy
(){
buildDeploy
(){
for
((
i
=
0
;
i<
${#
buildDeploys
[*]
}
;
i++
))
for
((
i
=
0
;
i<
${#
buildDeploys
[*]
}
;
i++
))
...
@@ -21,9 +21,6 @@ mvn install
...
@@ -21,9 +21,6 @@ mvn install
kubectl delete deployment ism-auth-service
-n
ism-service
kubectl delete deployment ism-auth-service
-n
ism-service
kubectl delete deployment ism-gateway-service
-n
ism-service
kubectl delete deployment ism-gateway-service
-n
ism-service
kubectl delete deployment ism-system-user-service
-n
ism-service
kubectl delete deployment ism-system-user-service
-n
ism-service
kubectl delete deployment ism-system-label-service
-n
ism-service
kubectl delete deployment ism-system-clue-service
-n
ism-service
kubectl delete deployment ism-wechat-service
-n
ism-service
docker images |
grep
-E
"(ism)"
|
awk
'{print $3}'
|
uniq
| xargs
-I
{}
docker rmi
--force
{}
docker images |
grep
-E
"(ism)"
|
awk
'{print $3}'
|
uniq
| xargs
-I
{}
docker rmi
--force
{}
...
@@ -38,15 +35,6 @@ docker push localhost:9999/ism/ism-gateway-service:latest
...
@@ -38,15 +35,6 @@ docker push localhost:9999/ism/ism-gateway-service:latest
echo
"==================system-user-service镜像==================="
echo
"==================system-user-service镜像==================="
docker build
-t
localhost:9999/ism/ism-system-user-service:latest
-f
system/system-user-service/DOCKERFILE
.
docker build
-t
localhost:9999/ism/ism-system-user-service:latest
-f
system/system-user-service/DOCKERFILE
.
docker push localhost:9999/ism/ism-system-user-service:latest
docker push localhost:9999/ism/ism-system-user-service:latest
echo
"==================system-clue-service镜像==================="
docker build
-t
localhost:9999/ism/system-clue-service:latest
-f
system/system-clue-service/DOCKERFILE
.
docker push localhost:9999/ism/system-clue-service:latest
echo
"==================system-label-service镜像==================="
docker build
-t
localhost:9999/ism/system-label-service:latest
-f
system/system-label-service/DOCKERFILE
.
docker push localhost:9999/ism/system-label-service:latest
echo
"==================wechat-service镜像==================="
docker build
-t
localhost:9999/ism/ism-wechat-service:latest
-f
wechat/wechat-service/DOCKERFILE
.
docker push localhost:9999/ism/ism-wechat-user-service:latest
echo
"docker镜像上传完毕,智能营销平台项目构建完毕"
echo
"docker镜像上传完毕,智能营销平台项目构建完毕"
echo
"清理缓存。。。"
echo
"清理缓存。。。"
mvn clean
mvn clean
...
@@ -57,11 +45,5 @@ echo "===========gateway-service=============="
...
@@ -57,11 +45,5 @@ echo "===========gateway-service=============="
kubectl create
-f
./gateway-service/deployment.yaml
kubectl create
-f
./gateway-service/deployment.yaml
echo
"===========user-service=============="
echo
"===========user-service=============="
kubectl create
-f
./system/system-user-service/deployment.yaml
kubectl create
-f
./system/system-user-service/deployment.yaml
echo
"===========label-service=============="
kubectl create
-f
./system/system-label-service/deployment.yaml
echo
"===========clue-service=============="
kubectl create
-f
./system/system-clue-service/deployment.yaml
echo
"===========wechat-service=============="
kubectl create
-f
./wechat/wechat-service/deployment.yaml
common/common-core/src/main/java/com/hungraim/ism/constant/WechatConstants.java
deleted
100644 → 0
View file @
321ba575
package
com
.
hungraim
.
ism
.
constant
;
/**
* @author hubin
*/
public
interface
WechatConstants
{
/**
* 获取access_token接口地址
*/
String
GET_TOKEN_URL
=
"https://qyapi.weixin.qq.com/cgi-bin/gettoken"
;
String
GET_USERID_FRO_CODE_URL
=
"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo"
;
String
GET_MOBILE_HASHCODE_URL
=
"https://qyapi.weixin.qq.com/cgi-bin/user/get_mobile_hashcode"
;
String
WECHAT_REDIS_KEY
=
"ism:system:wechat"
;
String
ACCESS_TOKEN_REDIS_KEY
=
"accessToken"
;
}
common/common-core/src/main/java/com/hungraim/ism/pojo/entity/system/SystemClientDetails.java
View file @
361ab204
...
@@ -13,9 +13,6 @@ public class SystemClientDetails {
...
@@ -13,9 +13,6 @@ public class SystemClientDetails {
private
String
clientId
;
private
String
clientId
;
private
String
resourceIds
;
private
String
resourceIds
;
private
String
clientSecret
;
private
String
clientSecret
;
/**
* 如果字段存的是enterpriseWechat,代表这个client是给到企业微信的app
*/
private
String
scope
;
private
String
scope
;
private
String
authorizedGrantTypes
;
private
String
authorizedGrantTypes
;
private
String
webServerRedirectUri
;
private
String
webServerRedirectUri
;
...
...
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