Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
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
fangxinjiang
yifu-mvp
Commits
0000a36f
Commit
0000a36f
authored
Jan 13, 2025
by
hongguangwu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/MVP1.7.5' into MVP1.7.5
parents
261130fd
48bb65f7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
WebSecurityConfiguration.java
...ud/plus/v1/yifu/auth/config/WebSecurityConfiguration.java
+4
-4
WxLoginAuthenticationFilter.java
...plus/v1/yifu/auth/filter/WxLoginAuthenticationFilter.java
+3
-4
YifuClientLoginSuccessHandler.java
...s/v1/yifu/auth/handler/YifuClientLoginSuccessHandler.java
+2
-0
YifuWxLoginSuccessHandler.java
.../plus/v1/yifu/auth/handler/YifuWxLoginSuccessHandler.java
+4
-1
No files found.
yifu-auth/src/main/java/com/yifu/cloud/plus/v1/yifu/auth/config/WebSecurityConfiguration.java
View file @
0000a36f
...
...
@@ -86,10 +86,10 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@SneakyThrows
protected
void
configure
(
HttpSecurity
http
)
{
http
.
addFilterBefore
(
getPasswordDecoderFilter
(),
PasswordDecoderFilter
.
class
)
.
formLogin
().
loginPage
(
"/token/login"
).
loginProcessingUrl
(
"/token/form"
)
.
failureHandler
(
authenticationFailureHandler
()).
and
().
logout
()
.
logoutSuccessHandler
(
logoutSuccessHandler
()).
deleteCookies
(
"JSESSIONID"
).
invalidateHttpSession
(
true
)
.
and
()
//
.formLogin().loginPage("/token/login").loginProcessingUrl("/token/form")
//
.failureHandler(authenticationFailureHandler()).and().logout()
//
.logoutSuccessHandler(logoutSuccessHandler()).deleteCookies("JSESSIONID").invalidateHttpSession(true)
//
.and()
.
authorizeRequests
().
antMatchers
(
"/**/login"
,
"/token/**"
,
"/actuator/**"
,
"/mobile/**"
,
"/oauth/token"
,
"/weixin/callback"
,
"/oauth/**"
,
"/wxLogin"
).
permitAll
()
.
anyRequest
().
authenticated
().
and
().
csrf
().
disable
();
}
...
...
yifu-auth/src/main/java/com/yifu/cloud/plus/v1/yifu/auth/filter/WxLoginAuthenticationFilter.java
View file @
0000a36f
...
...
@@ -41,7 +41,7 @@ public class WxLoginAuthenticationFilter extends AbstractAuthenticationProcessin
private
WxConfig
wxConfig
;
public
WxLoginAuthenticationFilter
()
{
super
(
new
AntPathRequestMatcher
(
SPRING_SECURITY_RESTFUL_LOGIN_URL
,
"
GE
T"
));
super
(
new
AntPathRequestMatcher
(
SPRING_SECURITY_RESTFUL_LOGIN_URL
,
"
POS
T"
));
}
/**
*
...
...
@@ -54,16 +54,15 @@ public class WxLoginAuthenticationFilter extends AbstractAuthenticationProcessin
@Override
public
Authentication
attemptAuthentication
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
AuthenticationException
{
if
(
!
postOnly
&&
!
request
.
getMethod
().
equals
(
"GE
T"
))
{
if
(
postOnly
&&
!
request
.
getMethod
().
equals
(
"POS
T"
))
{
throw
new
AuthenticationServiceException
(
"Authentication method not supported: "
+
request
.
getMethod
());
}
AbstractAuthenticationToken
authRequest
;
String
code
=
obtainParameter
(
request
,
"code"
);
if
(
Common
.
isEmpty
(
code
))
{
throw
new
AuthenticationServiceException
(
"未获取到授权码
"
);
throw
new
AuthenticationServiceException
(
"未获取到授权码
:"
+
code
);
}
// String result = restTemplate.getForObject(String.format(SecurityConstants.WX_GET_ACCOSS_TOKEN, wxConfig.getCorpid(), wxConfig.getCorpsecret()), String.class);
// if (Common.isEmpty(result)) {
// throw new AuthenticationServiceException("微信授权失败");
...
...
yifu-auth/src/main/java/com/yifu/cloud/plus/v1/yifu/auth/handler/YifuClientLoginSuccessHandler.java
View file @
0000a36f
...
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.auth.handler;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.CharsetUtil
;
import
cn.hutool.http.HttpStatus
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.yifu.cloud.plus.v1.yifu.auth.constants.SecurityConstants
;
...
...
@@ -164,6 +165,7 @@ public class YifuClientLoginSuccessHandler implements AuthenticationSuccessHandl
private
void
backResult
(
HttpServletResponse
response
,
R
result
)
throws
IOException
{
response
.
setCharacterEncoding
(
CharsetUtil
.
UTF_8
);
response
.
setContentType
(
CommonConstants
.
CONTENT_TYPE
);
response
.
setStatus
(
HttpStatus
.
HTTP_OK
);
PrintWriter
printWriter
=
response
.
getWriter
();
printWriter
.
append
(
objectMapper
.
writeValueAsString
(
result
));
}
...
...
yifu-auth/src/main/java/com/yifu/cloud/plus/v1/yifu/auth/handler/YifuWxLoginSuccessHandler.java
View file @
0000a36f
...
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.auth.handler;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.CharsetUtil
;
import
cn.hutool.http.HttpStatus
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.yifu.cloud.plus.v1.yifu.auth.constants.SecurityConstants
;
...
...
@@ -81,7 +82,7 @@ public class YifuWxLoginSuccessHandler implements AuthenticationSuccessHandler {
scope
.
add
(
"server"
);
TokenRequest
tokenRequest
=
new
TokenRequest
(
MapUtil
.
newHashMap
(),
"auth"
,
scope
,
"password"
);
//校验scope
ClientDetails
clientDetails
=
clientDetailsService
.
loadClientByClientId
(
null
);
ClientDetails
clientDetails
=
clientDetailsService
.
loadClientByClientId
(
"auth"
);
new
DefaultOAuth2RequestValidator
().
validateScope
(
tokenRequest
,
clientDetails
);
OAuth2Request
oAuth2Request
=
tokenRequest
.
createOAuth2Request
(
clientDetails
);
OAuth2Authentication
oAuth2Authentication
=
new
OAuth2Authentication
(
oAuth2Request
,
authentication
);
...
...
@@ -122,8 +123,10 @@ public class YifuWxLoginSuccessHandler implements AuthenticationSuccessHandler {
private
void
backResult
(
HttpServletResponse
response
,
R
result
)
throws
IOException
{
response
.
setCharacterEncoding
(
CharsetUtil
.
UTF_8
);
response
.
setContentType
(
CommonConstants
.
CONTENT_TYPE
);
response
.
setStatus
(
HttpStatus
.
HTTP_OK
);
PrintWriter
printWriter
=
response
.
getWriter
();
printWriter
.
append
(
objectMapper
.
writeValueAsString
(
result
));
log
.
info
(
"登录成功返回结果1111111:"
+
objectMapper
.
writeValueAsString
(
result
));
}
}
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