Skip to content

Commit

Permalink
Add a warning when allowCredentials is used with wildcard origin (#56)
Browse files Browse the repository at this point in the history
Fixes: #55
  • Loading branch information
rs authored May 24, 2018
1 parent ca016a0 commit 694cf2a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ func New(options Options) *Cors {
c.allowedMethods = convert(options.AllowedMethods, strings.ToUpper)
}

if c.allowedOriginsAll && c.allowCredentials {
// See https://github.com/rs/cors/issues/55
log.Print("[cors] WARNING: unsafe configuration: AllowOrigin * and AllowCredientials true combined")
}

return c
}

Expand All @@ -174,7 +179,7 @@ func AllowAll() *Cors {
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"HEAD", "GET", "POST", "PUT", "PATCH", "DELETE"},
AllowedHeaders: []string{"*"},
AllowCredentials: true,
AllowCredentials: false,
})
}

Expand Down

0 comments on commit 694cf2a

Please sign in to comment.