Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
antai-sport-http-server
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
antai-sport
antai-sport-http-server
Commits
2d168bc3
You need to sign in or sign up before continuing.
Commit
2d168bc3
authored
Apr 20, 2022
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决OPTION请求预校验问题
parent
73c3de6c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
AuthService.java
...ver/management/api/business/auth/service/AuthService.java
+1
-0
BaseConfig.java
...i/sport/http/server/management/api/config/BaseConfig.java
+1
-2
TokenInterceptor.java
...p/server/management/api/interceptor/TokenInterceptor.java
+6
-1
No files found.
management-api/src/main/java/com/antai/sport/http/server/management/api/business/auth/service/AuthService.java
View file @
2d168bc3
...
...
@@ -59,6 +59,7 @@ public class AuthService {
TokenVO
tokenVO
=
tokenService
.
initToken
(
loginParam
.
getUsername
());
result
.
setLongToken
(
tokenVO
.
getLongToken
());
result
.
setShortToken
(
tokenVO
.
getShortToken
());
result
.
setRefreshToken
(
true
);
result
.
setRespMsg
(
"登录成功"
);
return
result
;
}
...
...
management-api/src/main/java/com/antai/sport/http/server/management/api/config/BaseConfig.java
View file @
2d168bc3
package
com
.
antai
.
sport
.
http
.
server
.
management
.
api
.
config
;
import
com.antai.sport.http.server.common.resolver.SportUserArgumentResolver
;
import
com.antai.sport.http.server.management.api.interceptor.TokenInterceptor
;
import
com.antai.sport.http.server.management.api.resolver.SysUserArgumentResolver
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
...
...
@@ -30,7 +29,7 @@ public class BaseConfig implements WebMvcConfigurer {
registry
.
addMapping
(
"/**"
)
.
allowedOriginPatterns
(
"*"
)
.
allowCredentials
(
true
)
.
allowedMethods
(
"GET"
,
"POST"
,
"DELETE"
,
"PUT"
)
.
allowedMethods
(
"GET"
,
"POST"
,
"DELETE"
,
"PUT"
,
"OPTIONS"
)
.
maxAge
(
3600
);
}
...
...
management-api/src/main/java/com/antai/sport/http/server/management/api/interceptor/TokenInterceptor.java
View file @
2d168bc3
...
...
@@ -3,6 +3,8 @@ package com.antai.sport.http.server.management.api.interceptor;
import
com.antai.sport.http.server.common.jwt.TokenService
;
import
io.jsonwebtoken.Claims
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
javax.annotation.Resource
;
...
...
@@ -24,7 +26,10 @@ public class TokenInterceptor implements HandlerInterceptor {
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
String
token
=
request
.
getHeader
(
headerTokenKey
);
if
(
request
.
getMethod
().
equals
(
RequestMethod
.
OPTIONS
.
name
()))
{
response
.
setStatus
(
HttpStatus
.
OK
.
value
());
return
true
;
}
if
(
null
==
token
)
{
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
UNAUTHORIZED
.
getReasonPhrase
());
return
false
;
...
...
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