Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
youlai-mall
提交
8f80c65f
Y
youlai-mall
项目概览
有来技术
/
youlai-mall
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
youlai-mall
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8f80c65f
编写于
11月 24, 2020
作者:
H
haoxr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:认证服务器统一异常处理
上级
2740edfc
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
7 addition
and
8 deletion
+7
-8
youlai-auth/src/main/java/com/youlai/auth/config/AuthorizationServerConfig.java
...ava/com/youlai/auth/config/AuthorizationServerConfig.java
+5
-2
youlai-auth/src/main/java/com/youlai/auth/controller/AuthController.java
.../main/java/com/youlai/auth/controller/AuthController.java
+0
-1
youlai-auth/src/main/java/com/youlai/auth/exception/AuthExceptionHandler.java
.../java/com/youlai/auth/exception/AuthExceptionHandler.java
+2
-1
youlai-auth/src/main/java/com/youlai/auth/filter/CustomClientCredentialsTokenEndpointFilter.java
...th/filter/CustomClientCredentialsTokenEndpointFilter.java
+0
-2
youlai-auth/src/main/java/com/youlai/auth/service/UserDetailsServiceImpl.java
.../java/com/youlai/auth/service/UserDetailsServiceImpl.java
+0
-2
未找到文件。
youlai-auth/src/main/java/com/youlai/auth/config/AuthorizationServerConfig.java
浏览文件 @
8f80c65f
...
...
@@ -14,7 +14,6 @@ import lombok.SneakyThrows;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.buffer.DataBuffer
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.security.authentication.AuthenticationManager
;
...
...
@@ -31,7 +30,6 @@ import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFacto
import
org.springframework.security.web.AuthenticationEntryPoint
;
import
javax.sql.DataSource
;
import
java.nio.charset.Charset
;
import
java.security.KeyPair
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
...
...
@@ -88,6 +86,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
@Override
public
void
configure
(
AuthorizationServerSecurityConfigurer
security
)
{
/*security.allowFormAuthenticationForClients();*/
CustomClientCredentialsTokenEndpointFilter
endpointFilter
=
new
CustomClientCredentialsTokenEndpointFilter
(
security
);
endpointFilter
.
afterPropertiesSet
();
endpointFilter
.
setAuthenticationEntryPoint
(
authenticationEntryPoint
());
...
...
@@ -99,6 +98,10 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
}
/**
* 自定义认证异常响应数据
* @return
*/
@Bean
public
AuthenticationEntryPoint
authenticationEntryPoint
()
{
return
(
request
,
response
,
e
)
->
{
...
...
youlai-auth/src/main/java/com/youlai/auth/controller/AuthController.java
浏览文件 @
8f80c65f
...
...
@@ -73,7 +73,6 @@ public class AuthController {
@ApiIgnore
Principal
principal
,
@ApiIgnore
@RequestParam
Map
<
String
,
String
>
parameters
)
throws
HttpRequestMethodNotSupportedException
,
WxErrorException
{
log
.
info
(
"生成token开始"
);
String
clientId
=
parameters
.
get
(
"client_id"
);
if
(
StrUtil
.
isBlank
(
clientId
))
{
...
...
youlai-auth/src/main/java/com/youlai/auth/exception/AuthExceptionHandler.java
浏览文件 @
8f80c65f
package
com.youlai.auth.exception
;
import
com.youlai.common.core.result.Result
;
import
com.youlai.common.core.result.ResultCode
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.security.authentication.InternalAuthenticationServiceException
;
import
org.springframework.security.oauth2.common.exceptions.InvalidGrantException
;
...
...
@@ -19,7 +20,7 @@ public class AuthExceptionHandler {
*/
@ExceptionHandler
(
InvalidGrantException
.
class
)
public
Result
handleInvalidGrantException
(
InvalidGrantException
e
)
{
return
Result
.
error
(
e
.
getMessage
()
);
return
Result
.
custom
(
ResultCode
.
USERNAME_OR_PASSWORD_ERROR
);
}
...
...
youlai-auth/src/main/java/com/youlai/auth/filter/CustomClientCredentialsTokenEndpointFilter.java
浏览文件 @
8f80c65f
...
...
@@ -13,7 +13,6 @@ public class CustomClientCredentialsTokenEndpointFilter extends ClientCredential
private
AuthorizationServerSecurityConfigurer
configurer
;
private
AuthenticationEntryPoint
authenticationEntryPoint
;
public
CustomClientCredentialsTokenEndpointFilter
(
AuthorizationServerSecurityConfigurer
configurer
)
{
this
.
configurer
=
configurer
;
}
...
...
@@ -35,5 +34,4 @@ public class CustomClientCredentialsTokenEndpointFilter extends ClientCredential
setAuthenticationSuccessHandler
((
request
,
response
,
authentication
)
->
{
});
}
}
youlai-auth/src/main/java/com/youlai/auth/service/UserDetailsServiceImpl.java
浏览文件 @
8f80c65f
...
...
@@ -65,8 +65,6 @@ public class UserDetailsServiceImpl implements UserDetailsService {
throw
new
LockedException
(
"该账号已被锁定!"
);
}
else
if
(!
user
.
isAccountNonExpired
())
{
throw
new
AccountExpiredException
(
"该账号已过期!"
);
}
else
if
(!
user
.
isCredentialsNonExpired
())
{
throw
new
CredentialsExpiredException
(
"该账户的登录凭证已过期,请重新登录!"
);
}
return
user
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录