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

Optional ACAHs: X-XSRF-TOKEN #2578

Closed
iutipikin opened this issue Jul 26, 2018 · 6 comments
Closed

Optional ACAHs: X-XSRF-TOKEN #2578

iutipikin opened this issue Jul 26, 2018 · 6 comments

Comments

@iutipikin
Copy link

Hi everyone!

I'm using latest version (2.9.2) of this awesome project to describe my endpoints. Some of them are secured by Keycloak server (OAuth2 authorization flow) and i implemented a Swagger-UI OAuth2 security schema. Everything seems ok, but what's the problem? Keycloak server (which i'm not in control) not allow 'Access-Control-Allowed-Headers : x-xsrf-token' header, so then i'm trying to get JWT, request which made by swagger-ui always blocked by mu IDP.

Can this feature - sending CSRF token to external IDP endpoint may be optional?

@iutipikin
Copy link
Author

Ok, I found what if I implement /csrf endpoint (for not getting HTTP/404) X-XSRF-TOKEN will be added to access headers automaticaly by this function getCsrfFromCookie() from springfox-swagger-ui/src/web/js/csrf.js.
Is it possible to provide some flag from SecurityConfiguration to that function's context?

@dilipkrish
Copy link
Member

@iutipikin seems like you're further along in the research than I am. Would be happy to accept any fix you think might fix it.

@olOwOlo
Copy link
Contributor

olOwOlo commented Aug 24, 2018

Ok, I wrote it in #2434 . ORZ 😢
Because I didn't know how to add options, I can only try to fetch the CSRF token. There are three steps:

  1. fetch http://your-base-url/
  2. fetch http://your-base-url/csrf
  3. search your cookie

If your server do not support csrf, you'll see two 404 requests, but everything is ok and there are no errors. These requests are just trying to find your csrf token. If a csrf token is found, it will be automatically added to your request header.

I guess I found how to add options, I will send a pr to make these behaviors optional.


Related issues: #2633 #2603 #2573

@fennekit
Copy link

Pull request #2706

@dilipkrish
Copy link
Member

Thank you @fennekit

@ajmalch
Copy link

ajmalch commented Mar 12, 2019

Thank you @fennekit

@dilipkrish , We are also facing the same issue #2633. Do you think the PR @fennekit created will resolve the issue and if yes, can we expect this in the next version?

@dilipkrish dilipkrish added this to the 3.0 milestone Aug 3, 2019
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

5 participants