Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cneeds-server
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
zhangzr
cneeds-server
Commits
ec75ecf6
Commit
ec75ecf6
authored
Mar 06, 2020
by
zzrdark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
springsecurity跨域问题
parent
7435e5f3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
5 deletions
+6
-5
OAuth2ResourceServer.java
...x/cneeds/server/datashow/config/OAuth2ResourceServer.java
+1
-1
WebConfig.java
.../java/com/mx/cneeds/server/datashow/config/WebConfig.java
+1
-1
CrossFilter.java
...ava/com/mx/cneeds/server/datashow/filter/CrossFilter.java
+1
-2
UserController.java
...om/mx/cneeds/server/datashow/web/user/UserController.java
+3
-1
No files found.
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/config/OAuth2ResourceServer.java
View file @
ec75ecf6
...
@@ -26,7 +26,7 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
...
@@ -26,7 +26,7 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
// 开启认证
// 开启认证
.
anyRequest
()
.
anyRequest
()
.
authenticated
()
.
authenticated
()
.
and
();
.
and
()
.
cors
().
and
().
csrf
().
disable
()
;
}
}
...
...
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/config/WebConfig.java
View file @
ec75ecf6
...
@@ -30,7 +30,7 @@ public class WebConfig implements WebMvcConfigurer {
...
@@ -30,7 +30,7 @@ public class WebConfig implements WebMvcConfigurer {
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
registry
.
addMapping
(
"/**"
)
.
allowedOrigins
(
"*"
)
.
allowedOrigins
(
"*"
)
.
allowedMethods
(
"GET"
,
"HEAD"
,
"POST"
,
"PUT"
,
"DELETE"
,
"OPTIONS"
,
"AUTHORIZATION"
)
.
allowedMethods
(
"GET"
,
"HEAD"
,
"POST"
,
"PUT"
,
"DELETE"
,
"OPTIONS"
)
.
allowCredentials
(
true
)
.
allowCredentials
(
true
)
.
maxAge
(
3600
)
.
maxAge
(
3600
)
.
allowedHeaders
(
"*"
);
.
allowedHeaders
(
"*"
);
...
...
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/filter/CrossFilter.java
View file @
ec75ecf6
...
@@ -34,9 +34,8 @@ public class CrossFilter implements Filter {
...
@@ -34,9 +34,8 @@ public class CrossFilter implements Filter {
httpResponse
.
setHeader
(
"Access-Control-Allow-Methods"
,
"*"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Methods"
,
"*"
);
httpResponse
.
setHeader
(
"Access-Control-Max-Age"
,
"3600"
);
httpResponse
.
setHeader
(
"Access-Control-Max-Age"
,
"3600"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Headers"
,
httpResponse
.
setHeader
(
"Access-Control-Allow-Headers"
,
"Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie, Authorization"
);
"Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie, Authorization
,Access-Control-Allow-Origin
"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Credentials"
,
"true"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Credentials"
,
"true"
);
// httpResponse.setHeader("Content-type", "application/json");
httpResponse
.
setHeader
(
"Cache-Control"
,
"no-cache, must-revalidate"
);
httpResponse
.
setHeader
(
"Cache-Control"
,
"no-cache, must-revalidate"
);
filterChain
.
doFilter
(
request
,
httpResponse
);
filterChain
.
doFilter
(
request
,
httpResponse
);
}
}
...
...
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/user/UserController.java
View file @
ec75ecf6
...
@@ -4,12 +4,14 @@ import com.mx.cneeds.common.result.R;
...
@@ -4,12 +4,14 @@ import com.mx.cneeds.common.result.R;
import
com.mx.cneeds.common.vo.UserInfoVo
;
import
com.mx.cneeds.common.vo.UserInfoVo
;
import
com.mx.cneeds.server.datashow.client.AuthorizationClient
;
import
com.mx.cneeds.server.datashow.client.AuthorizationClient
;
import
com.mx.cneeds.common.dto.JwtToken
;
import
com.mx.cneeds.common.dto.JwtToken
;
import
com.netflix.client.http.HttpResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
/**
/**
...
@@ -42,7 +44,7 @@ public class UserController {
...
@@ -42,7 +44,7 @@ public class UserController {
}
}
@RequestMapping
(
"/info"
)
@RequestMapping
(
"/info"
)
public
R
getInfo
(){
public
R
getInfo
(
HttpServletResponse
response
){
UserInfoVo
userInfoVo
=
new
UserInfoVo
();
UserInfoVo
userInfoVo
=
new
UserInfoVo
();
log
.
info
(
"getInfo"
);
log
.
info
(
"getInfo"
);
userInfoVo
.
setName
(
"admin"
);
userInfoVo
.
setName
(
"admin"
);
...
...
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