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

Is there a way, how I can disable csrf for swagger? #5153

Open
SpamhaterAlex opened this issue Feb 4, 2019 · 1 comment
Open

Is there a way, how I can disable csrf for swagger? #5153

SpamhaterAlex opened this issue Feb 4, 2019 · 1 comment

Comments

@SpamhaterAlex
Copy link

Hi together,

I use a double submit technique to prevent an unauthorized and unwarranted access. This carries a restriction of usage of Swagger. In my current setup to prove that I have "the right to write", I should manually copy a security token (x-xsrf-token) from the last request to the new request every time, if I want to interact with my API using PUT, POST or DELETE method.

Is there a way, how I can disable csrf for swagger?
Or do you have an idea, how I can solve my issue?

Thanks

@shockey
Copy link
Contributor

shockey commented Feb 11, 2019

Hi @SpamhaterAlex!

The specification doesn't have good support for this use case at the moment. There is some work going on around authentication in general (see OAI/OpenAPI-Specification#451 (comment), for example), so now would be a good time to start a discussion about it over at OpenAPI. That said - if your x-xsrf-token isn't standards-based, it's unlikely that it would ever be included in the specification. Also, CSRF is becoming less relevant over time, as browsers add user-agent level support for controls over cross-origin request cookie inclusion.

My suggestion would be to either use a requestInterceptor to manually capture and attach the latest xsrf token to requests programmatically, or modify your server to disable your CSRF mechanism for Swagger UI somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants