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

[BUG] Authentication not working with oauth2 #170

Open
thomasuebi opened this issue Jul 14, 2021 · 3 comments
Open

[BUG] Authentication not working with oauth2 #170

thomasuebi opened this issue Jul 14, 2021 · 3 comments
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@thomasuebi
Copy link

Describe the bug
Authentication not working with oauth2.
To Reproduce
Trying to implement oauth2 according to swagger documentation.

security: {
    BearerAuth: {
      type: "oauth2",
      scheme: "bearer",
    },
  }

Does not work unfortunately. Also, I can not add scope and token URL information.
Expected behavior
I want to be able to add OAuth2 authentication method to swagger config, including scope and token URL information

@kevinccbsg kevinccbsg added bug Something isn't working enhancement New feature or request good first issue Good for newcomers labels Jul 19, 2021
@kevinccbsg
Copy link
Member

Hi @thomasuebi,

Thanks for reporting. I'm sure it is not working so we will work on this asap. 👍

@kevinccbsg kevinccbsg changed the title [BUG] [BUG] Authentication not working with oauth2 Aug 2, 2021
@kevinccbsg
Copy link
Member

Hi,

I uploaded a workaround for this in this PR #183. In that PR I'm using the merge option this library has.

It does not solve the issue but at least provides a solution.

Actually, we are dealing with the way of solving this, in terms of how should we ask the developer to complete OAuth2 info?

For example

{
  "components": {
    "securitySchemes": {
      "oAuthSample": {
        "type": "oauth2",
        "description": "This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)",
        "flows": {
          "implicit": {
            "authorizationUrl": "https://api.example.com/oauth2/authorize",
            "scopes": {
              "read_pets": "read your pets",
              "write_pets": "modify pets in your account"
            }
          }
        }
      }
    }
  }
}

Adding this in a JSDOC comment I am not sure about that 🤔 Also we have to control which scopes we add for each endpoint. I guess that one is easier to solve we could do something like this

@security oauth: scope1, scope2

We will continue working on this, and we'll be glad to hear suggestions for this feature.

@bqp-articulate
Copy link

I'm working on an API that uses OpenID and would be happy to try testing the fix when it's available. Note that there's an additional bug in swagger-ui that I ran into: swagger-api/swagger-ui#8315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants