Skip to content

Do not implicitly allow OPTIONS in CORS config - #46

Open
AshSgDe29071999 wants to merge 1 commit into
go-chi:masterfrom
AshSgDe29071999:fix/do-not-implicitly-allow-options
Open

AshSgDe29071999 wants to merge 1 commit into
go-chi:masterfrom
AshSgDe29071999:fix/do-not-implicitly-allow-options

Conversation

@AshSgDe29071999

Copy link
Copy Markdown

Fixes #37

isMethodAllowed treated OPTIONS as always allowed so a preflight with Access-Control-Request-Method: OPTIONS succeeded even when OPTIONS was not in AllowedMethods. That lets browsers follow up with an actual OPTIONS request the server did not opt into.

Preflight still works: the HTTP method of the preflight is OPTIONS regardless, and Access-Control-Allow-Methods now reflects only configured methods. List OPTIONS explicitly when the server wants to allow non-preflight OPTIONS.

isMethodAllowed treated OPTIONS as always allowed, so a preflight with
Access-Control-Request-Method: OPTIONS succeeded even when OPTIONS was
not in AllowedMethods. Actual OPTIONS requests are uncommon; only list
OPTIONS when the server intends to allow them.

See go-chi#37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Middleware unduly allow OPTIONS requests

1 participant