swagger-api / swagger-api/swagger-ui

Scopes not updated on modal when I change definitions

Open
#6,543 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

cat: auth
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A
  • OS: macOS
  • Browser: chrome
  • Version: 86.0.4240.80
  • Method of installation: dist assets
  • Swagger-UI version: 3.35.2
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Swagger-UI configuration options:

window.ui = SwaggerUIBundle({
    urls: specsUrls,
    dom_id: '#swagger-ui',
    filter: true,
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: 'StandaloneLayout',
    validatorUrl: null,
    oauth2RedirectUrl: defaultRedirectUrl
  });

I use two specifications on two different urls:

Account:

{
  "openapi": "3.0.1",
  "info": {
    "title": "Account",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "/api"
    }
  ],
  "paths": {
    "/accounts/v1/me": {
      "get": {
        ...,
        "security": [
          {
            "Oauth2Application": [
              "read:me"
            ]
          },
          {
            "Oauth2AuthorizationCode": [
              "read:me"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      ...
    },
    "securitySchemes": {
      "Oauth2Application": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "XXX",
            "scopes": {
              "read:me": "Self account read",
              "write:me": "Self account write"
            }
          }
        }
      },
      "Oauth2AuthorizationCode": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "XXX",
            "tokenUrl": "XXX",
            "scopes": {
              "read:me": "Self account read",
              "write:me": "Self account write"
            }
          }
        }
      }
    }
  }
}

And Assets:

{
  "openapi": "3.0.1",
  "info": {
    "title": "Assets",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "/api/assets/v1"
    }
  ],
  "paths": {
    "/assets": {
      "get": {
        ...,
        "security": [
          {
            "Oauth2Application": [
              "read:assets"
            ]
          },
          {
            "Oauth2AuthorizationCode": [
              "read:assets"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      ...
    },
    "securitySchemes": {
      "Oauth2Application": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "XXX",
            "scopes": {
              "read:assets": "Read your assets",
              "write:assets": "Create and update your assets"
            }
          }
        }
      },
      "Oauth2AuthorizationCode": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "XXX",
            "tokenUrl": "XXX",
            "scopes": {
              "read:assets": "Read your assets",
              "write:assets": "Create and update your assets"
            }
          }
        }
      }
    }
  }
}
Description

Hello !

I have one problem on scopes on oauth2 modal when I use the topbar component: it seems the scopes are not reloaded on url change.

To reproduce...

Steps to reproduce the behavior:

  1. Go to default definition ("Account")
  2. Click on Authorize button
  3. See "Account" scopes "read:me" and "write:me"
  4. Close modal
  5. Change definition to "Assets"
  6. Click on Authorize button
  7. See "Account" scopes "read:me" and "write:me" instead of "Assets" scopes "read:assets" and "write:assets"
Expected behavior

On step 7, I wan't to see the "Assets" scopes.

Screenshots
Capture d’écran 2020-10-21 à 18 06 25

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the two Account and Assets OpenAPI definitions, using the topbar definition selector and OAuth2 authorize modal. Inspect the authorize modal's handling of definition changes; done means switching to Assets shows read:assets and write:assets instead of the Account scopes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.