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

Swagger UI does not pick the correct OAuth endpoint during authentication #1410

Closed
bertramn opened this issue Jun 25, 2015 · 3 comments
Closed

Comments

@bertramn
Copy link

I am having issues to get swagger-ui to work with an API that requires access tokens from 2 different issuers. The OAuth setup works for a single issuer. However when I add another issuer into the swagger.json and adjust the security tag on some methods to use the other issuer, the swagger-ui only ever pics the last issuer in the list to present the logon screen. Below the setup I roughly have:

the 2 methods:

"/methodA": {"get": {
  "tags": ["a"],
  "summary": "method A is only accessible with tokens from issuer A",
  "consumes": ["application/json"],
  "produces": ["application/json"],
  "parameters": [],
  "responses": {"200": {
    "description": "successful operation",
    "schema": {"type": "string"}
  }},
  "security": [{"iss_a": []}]
}}
"/methodB": {"get": {
  "tags": ["b"],
  "summary": "method B is only accessible with tokens from issuer B",
  "consumes": ["application/json"],
  "produces": ["application/json"],
  "parameters": [],
  "responses": {"200": {
    "description": "successful operation",
    "schema": {"type": "string"}
  }},
  "security": [{"iss_b": []}]
}}

the issuers configuration

"securityDefinitions": {
  "iss_a": {
    "type": "oauth2",
    "authorizationUrl": "https://login.issuer-a.com/authorize",
    "flow": "implicit",
    "scopes": {"openid": ""}
  },
  "iss_b": {
    "type": "oauth2",
    "authorizationUrl": "https://login.issuer-b.com/authorize",
    "flow": "implicit",
    "scopes": {"openid": ""}
  }
}

I am using swagger 2.0 spec with swagger-ui version 2.1.0. I also tried the develop_2.0 branch without much luck.

Anyone got any suggestions of what may be going wrong here?

Thanks a lot.

@fehguy
Copy link
Contributor

fehguy commented Dec 9, 2015

I believe this is a limitation of the current implementation. It does not expect to have multiple issuers--I'll flag this as a feature enhancement.

@TomDemeranville
Copy link
Contributor

Fixed. You can now select from multiple authentication schemes/issuers/securityDefinitions.

Pull request here: #1825

@fehguy
Copy link
Contributor

fehguy commented Dec 18, 2015

this has been merged to master

@fehguy fehguy closed this as completed Dec 18, 2015
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

3 participants