Change server default allowed origin (#931)
This commit is contained in:
1 parent
e9da3a871d
commit
0993747702
3 files changed
+8
-6
No files matched your search
+3
-4
@@ -22,10 +22,9 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.
|
||||
`create` or `list`. This format operates only on collections so assigning
|
||||
more actions this way will never work
|
||||
* CORS: CORS is now turned on by default when running with `boundary server`
|
||||
with an `allowed_origins` value of `*`. You can disable it with `cors_enabled
|
||||
= false` or if you want to change parameters, set `cors_enabled = true` and
|
||||
the other related configuration values. It was always turned on when running
|
||||
`boundary dev` and this provides a more consistent experience.
|
||||
with an `allowed_origins` value of `serve://boundary`. You can disable it with
|
||||
`cors_enabled = false`, or if you want to change parameters, set `cors_enabled
|
||||
= true` and the other related configuration values.
|
||||
|
||||
### New and Improved
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ func Parse(d string) (*Config, error) {
|
||||
if listener.CorsEnabled == nil {
|
||||
listener.CorsEnabled = new(bool)
|
||||
*listener.CorsEnabled = true
|
||||
listener.CorsAllowedOrigins = []string{"*"}
|
||||
listener.CorsAllowedOrigins = []string{"serve://boundary"}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,12 +279,15 @@ func wrapHandlerWithCors(h http.Handler, props HandlerProperties) http.Handler {
|
||||
case len(allowedOrigins) == 0:
|
||||
// not valid
|
||||
|
||||
case len(allowedOrigins) == 1 && allowedOrigins[0] == "*":
|
||||
case len(allowedOrigins) == 1 &&
|
||||
(allowedOrigins[0] == "*" ||
|
||||
allowedOrigins[0] == "serve://boundary"):
|
||||
valid = true
|
||||
|
||||
default:
|
||||
valid = strutil.StrListContains(allowedOrigins, origin)
|
||||
}
|
||||
|
||||
if !valid {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
|
||||
Reference in new issue
Block a user