Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Plan
Issues
27
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
ARSnova Backend
Commits
87cd1654
Commit
87cd1654
authored
5 years ago
by
Daniel Gerhardt
Browse files
Options
Downloads
Plain Diff
Merge branch 'http-constants' into 'master'
Use constants for HTTP methods and header names See merge request
!143
parents
132a42fd
802fcd6a
Branches
Branches containing commit
1 merge request
!143
Use constants for HTTP methods and header names
Pipeline
#29657
passed with warnings with stages
Stage:
Stage:
Stage:
in 2 minutes and 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/thm/arsnova/web/CorsFilter.java
+14
-11
14 additions, 11 deletions
src/main/java/de/thm/arsnova/web/CorsFilter.java
with
14 additions
and
11 deletions
src/main/java/de/thm/arsnova/web/CorsFilter.java
+
14
−
11
View file @
87cd1654
...
...
@@ -21,10 +21,13 @@ package de.thm.arsnova.web;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
public
class
CorsFilter
extends
org
.
springframework
.
web
.
filter
.
CorsFilter
{
private
static
final
String
X_REQUESTED_WITH
=
"X-Requested-With"
;
private
static
final
String
TOKEN_HEADER_NAME
=
"Arsnova-Auth-Token"
;
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CorsFilter
.
class
);
...
...
@@ -41,24 +44,24 @@ public class CorsFilter extends org.springframework.web.filter.CorsFilter {
/* Grant full access from specified origins */
config
=
new
CorsConfiguration
();
config
.
setAllowedOrigins
(
origins
);
config
.
addAllowedHeader
(
"Accept"
);
config
.
addAllowedHeader
(
"Content-Type"
);
config
.
addAllowedHeader
(
"X-Requested-With"
);
config
.
addAllowedHeader
(
HttpHeaders
.
ACCEPT
);
config
.
addAllowedHeader
(
HttpHeaders
.
CONTENT_TYPE
);
config
.
addAllowedHeader
(
X_REQUESTED_WITH
);
config
.
addAllowedHeader
(
TOKEN_HEADER_NAME
);
config
.
addAllowedMethod
(
"
GET
"
);
config
.
addAllowedMethod
(
"
POST
"
);
config
.
addAllowedMethod
(
"
PUT
"
);
config
.
addAllowedMethod
(
"
PATCH
"
);
config
.
addAllowedMethod
(
"
DELETE
"
);
config
.
addAllowedMethod
(
HttpMethod
.
GET
);
config
.
addAllowedMethod
(
HttpMethod
.
POST
);
config
.
addAllowedMethod
(
HttpMethod
.
PUT
);
config
.
addAllowedMethod
(
HttpMethod
.
PATCH
);
config
.
addAllowedMethod
(
HttpMethod
.
DELETE
);
config
.
setAllowCredentials
(
true
);
source
.
registerCorsConfiguration
(
"/**"
,
config
);
}
else
{
/* Grant limited access from all origins */
config
=
new
CorsConfiguration
();
config
.
addAllowedOrigin
(
"*"
);
config
.
addAllowedHeader
(
"Accept"
);
config
.
addAllowedHeader
(
"X-Requested-With"
);
config
.
addAllowedMethod
(
"
GET
"
);
config
.
addAllowedHeader
(
HttpHeaders
.
ACCEPT
);
config
.
addAllowedHeader
(
X_REQUESTED_WITH
);
config
.
addAllowedMethod
(
HttpMethod
.
GET
);
source
.
registerCorsConfiguration
(
"/"
,
config
);
source
.
registerCorsConfiguration
(
"/arsnova-config"
,
config
);
source
.
registerCorsConfiguration
(
"/configuration/"
,
config
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment