Skip to content

Support cookie based security validation? #280

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

Closed
tkarls opened this issue Apr 24, 2020 · 7 comments
Closed

Support cookie based security validation? #280

tkarls opened this issue Apr 24, 2020 · 7 comments

Comments

@tkarls
Copy link

tkarls commented Apr 24, 2020

I have an API and added both Bearer token authentication as well as support for sessions with cookies. But now the openapi validater never ever complain about missing credentials if I have them both listed in the security array.

It works as expected when I only use bearer auth (getting 401 and error message if no bearer token is present). But as soon as I add the cookie based auth to the security array the validator doesn't complain about missing tokens or missing cookies for that matter.

It took me a while to pinpoint but I think the problem is that cookie auth was never implemented and then it always treat that as successful even if no cookie is present. See below.

@cdimascio
Copy link
Owner

@tkarls Yep. We need to get this implemented.
Would you mind providing the relevant snippet from your API spec

@cdimascio
Copy link
Owner

initial cookie auth support: b7d7afc

@cdimascio
Copy link
Owner

@tkarls please give v3.12.5 a try. let me know if suits your needs.

@cdimascio
Copy link
Owner

@tkarls this is fixed in the latest version, please re-open if you still have issues. Thank you!

@tkarls
Copy link
Author

tkarls commented Apr 27, 2020

@cdimascio Wow, this was quick 😁

I will test the latest version during the day!
Many thanks!

@tkarls
Copy link
Author

tkarls commented Apr 27, 2020

@cdimascio
I have tested it in my project now and it works!
Only small thing left would be that it only returns the error of the first validation that failed. So if I don't send in any cookie nor any token I get an error message that complains about only one of them (the first that failed) which is the first I list in the openapi spec.

Which is different from other request validations where I get an array of all errors encountered back.

However, since with the auth errors it is sufficient to have ONE of them correct it might not be the best approach to return them as an array either. Since that can be interpreted as all of them need to be fulfilled.

Anyway, the important thing is that the validation is working. So thanks again for your rapid fix :) !

@cdimascio
Copy link
Owner

thanks @tkarls. i'll create a ticket for the errors. will be good to have the same representation

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