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

Forwarding CSRF token in cookie with requests #431

Closed
alecvn opened this issue Jun 8, 2021 · 2 comments
Closed

Forwarding CSRF token in cookie with requests #431

alecvn opened this issue Jun 8, 2021 · 2 comments
Labels

Comments

@alecvn
Copy link

alecvn commented Jun 8, 2021

According to the following documentation it should be possible to forward cookies with Swagger:
https://swagger.io/docs/specification/authentication/cookie-authentication/

In swagger_helper.rb I have the following:

    'v1/swagger.yaml' => {
      openapi: '3.0.1',
      # swagger: '2.0',
      components: {
        securitySchemes: {
          cookieAuth: {         # arbitrary name for the security scheme; will be used in the "security" key later
            type: "apiKey",
            in: "cookie",
            name: "CSRF-TOKEN"
          }
        }
      },
      security: {
        cookieAuth: []
      },
      info: {
        title: 'API V1',
        version: 'v1'
      },
  ...-

However the CSRF-TOKEN isn't added to the cookies forwarded with my request.

I was also unable to locate where I would configure to include credentials if that were necessary.

@jaydorsey
Copy link
Contributor

The in: "cookie" syntax looks incorrect to me; it should probably be in: :header. A cookie is simply a type of header attribute/value

In order to set it, you'll also need to use something like let(:'CSRF-TOKEN') { 'my-token-value' } in your spec in order to pass it into the request

You'll also need your security: [cookieAuth: []] syntax in your spec, if you don't have it

@stale
Copy link

stale bot commented Aug 10, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If the issue is still relevant to you, please leave a comment stating so to keep the issue from being closed. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 10, 2022
@stale stale bot closed this as completed Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants