Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin validation on OPTIONS #58

Open
slashmili opened this issue Oct 22, 2018 · 3 comments
Open

Origin validation on OPTIONS #58

slashmili opened this issue Oct 22, 2018 · 3 comments

Comments

@slashmili
Copy link
Contributor

Do you think if it's necessary to do check the request's origin against the configuration on OPTIONS request?

@CrowdHailer
Copy link
Contributor

Doesn't the line below the one you linked to recall the headers function but with method set to nil so that it goes on to check the requests origin here.

headers(%{conn | method: nil}, options) ++

then
allowed_origin = origin(options[:origin], conn)

@slashmili
Copy link
Contributor Author

What I mean is in here

defp headers(conn = %Plug.Conn{method: "OPTIONS"}, options) do
headers(%{conn | method: nil}, options) ++
[
{"access-control-max-age", "#{options[:max_age]}"},
{"access-control-allow-headers", allowed_headers(options[:headers], conn)},
{"access-control-allow-methods", options[:methods]}
]
end

we always set access-control-* headers regardless of the origin is set in configuration or not

@CrowdHailer
Copy link
Contributor

Ahh yes I see. Same check as is found here

defp cors_headers(nil, _options) do

Could you add a test case that fails because of how it is currently set up. Then we can work out the best way to fix it

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

No branches or pull requests

2 participants