Skip to content

Conversation

@yinzara
Copy link
Contributor

@yinzara yinzara commented May 27, 2020

Description

This PR adds a "scopes" option to the "ui.initOAuth" function.

This option can be an array of strings or a string separated by the "scopeSeparator" option (or space by default).

If specified, the Authorize pop-up will have the given set of scopes automatically selected.

Additionally, this PR also adds a "select all" and "select none" link to cause all/no scopes to be selected. See screenshot.

Motivation and Context

When using Swagger UI's OAuth functionality with an API that has multiple scopes, it can be extremely tedious to select all (or a specific set).

Fixes #2531

How Has This Been Tested?

I have updated the Selenium e2e configuration for initOAuth to specify the "scopes" option as "read:pets openid profile".
I then updated the "schemeContainer render click event" test (and main.js schemeContainer) to test the presence of the "read:pets" checkbox as being checked and the "write:pets" checkbox as being unchecked. I then click the select all and select none links and verify the scopes are properly selected.

Screenshots:

Screen Shot 2020-05-27 at 6 29 22 PM

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@yinzara yinzara changed the title improvement: oauth "scopes" init parameter improvement: oauth "scopes" improvements May 28, 2020
@yinzara
Copy link
Contributor Author

yinzara commented Jun 2, 2020

@webron @tim-lai @shockey Could I get some love for this PR?

It's fully selenium tested, includes screen shots, and fixes a filed issue.

@tim-lai
Copy link
Contributor

tim-lai commented Jun 3, 2020

@yinzara I will take a look at this "soon". Thanks for the PR and patience!

@tim-lai tim-lai self-assigned this Jun 3, 2020
@tim-lai tim-lai merged commit 275c8f2 into swagger-api:master Jun 10, 2020
@tim-lai
Copy link
Contributor

tim-lai commented Jun 10, 2020

@yinzara Merged! Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Implement OAuth2 scopes all/none toggling in the auth dialog

3 participants