Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7780c171
Commit
7780c171
authored
Nov 17, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17093 from Pendoragon/master
Auto commit by PR queue bot
parents
ac0d0095
6d94dd1a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
master.go
pkg/master/master.go
+14
-10
No files found.
pkg/master/master.go
View file @
7780c171
...
...
@@ -713,21 +713,12 @@ func (m *Master) init(c *Config) {
}
handler
:=
http
.
Handler
(
m
.
mux
.
(
*
http
.
ServeMux
))
insecureHandler
:=
handler
// TODO: handle CORS and auth using go-restful
// See github.com/emicklei/go-restful/blob/master/examples/restful-CORS-filter.go, and
// github.com/emicklei/go-restful/blob/master/examples/restful-basic-authentication.go
if
len
(
c
.
CorsAllowedOriginList
)
>
0
{
allowedOriginRegexps
,
err
:=
util
.
CompileRegexps
(
c
.
CorsAllowedOriginList
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Invalid CORS allowed origin, --cors-allowed-origins flag was set to %v - %v"
,
strings
.
Join
(
c
.
CorsAllowedOriginList
,
","
),
err
)
}
handler
=
apiserver
.
CORS
(
handler
,
allowedOriginRegexps
,
nil
,
nil
,
"true"
)
}
m
.
InsecureHandler
=
handler
attributeGetter
:=
apiserver
.
NewRequestAttributeGetter
(
m
.
requestContextMapper
,
m
.
newRequestInfoResolver
())
handler
=
apiserver
.
WithAuthorizationCheck
(
handler
,
attributeGetter
,
m
.
authorizer
)
...
...
@@ -740,6 +731,19 @@ func (m *Master) init(c *Config) {
handler
=
authenticatedHandler
}
// Since OPTIONS request cannot carry authn headers (by w3c standards), we are doing CORS check
// before auth check. Otherwise all the CORS request will be rejected.
if
len
(
c
.
CorsAllowedOriginList
)
>
0
{
allowedOriginRegexps
,
err
:=
util
.
CompileRegexps
(
c
.
CorsAllowedOriginList
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Invalid CORS allowed origin, --cors-allowed-origins flag was set to %v - %v"
,
strings
.
Join
(
c
.
CorsAllowedOriginList
,
","
),
err
)
}
handler
=
apiserver
.
CORS
(
handler
,
allowedOriginRegexps
,
nil
,
nil
,
"true"
)
insecureHandler
=
apiserver
.
CORS
(
insecureHandler
,
allowedOriginRegexps
,
nil
,
nil
,
"true"
)
}
m
.
InsecureHandler
=
insecureHandler
// Install root web services
m
.
handlerContainer
.
Add
(
m
.
rootWebService
)
...
...
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