Skip to content

Commit

Permalink
fix CORS origins to avoid domain hijacking
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
  • Loading branch information
marcosnils committed Mar 2, 2023
1 parent 2b95e66 commit ed82247
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions handlers/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func Register(extend HandlerExtender) {

corsHandler := gh.CORS(gh.AllowCredentials(), gh.AllowedHeaders([]string{"x-requested-with", "content-type"}), gh.AllowedMethods([]string{"GET", "POST", "HEAD", "DELETE"}), gh.AllowedOriginValidator(func(origin string) bool {
if strings.Contains(origin, "localhost") ||
strings.HasSuffix(origin, "play-with-docker.com") ||
strings.HasSuffix(origin, "play-with-kubernetes.com") ||
strings.HasSuffix(origin, "docker.com") ||
strings.HasSuffix(origin, "play-with-go.dev") {
strings.HasSuffix(origin, ".play-with-docker.com") ||
strings.HasSuffix(origin, ".play-with-kubernetes.com") ||
strings.HasSuffix(origin, ".docker.com") ||
strings.HasSuffix(origin, ".play-with-go.dev") {
return true
}
return false
Expand Down

0 comments on commit ed82247

Please sign in to comment.