redoc icon indicating copy to clipboard operation
redoc copied to clipboard

Support security OAuth2 scopes on operations

Open jimmyjames opened this issue 9 years ago • 16 comments

Operations may define the required OAuth2 scope. For example, in the example PetStore spec, to POST to the /pet endpoint to create a new Pet, it is required that the token have read and write permissions:

security:
  - petstore_auth
      - 'write:pets'
      - 'read:pets'

You can see from the demo that the required auth scopes are not shown for the operation.

Is it on the near-term roadmap to support rendering the required auth scopes for an operation? We are loving ReDoc, but this is a pretty big deal as users need to know the required auth scope.

jimmyjames avatar Jun 14 '17 14:06 jimmyjames

If this is something that is agreed-upon as a good feature, I'm willing to help with a PR to get this in.

jimmyjames avatar Jun 15 '17 15:06 jimmyjames

I have this working by showing any OAuth2 scopes beneath the responses for each operation (won't display if there are no oauth2 scopes for an operation):

image

There are other UX possibilities of course, like adding the security info all in a tip (for example with a little padlock icon that shows the security scopes when hovering over, next to the operation description).

I'll follow with a PR for what I've done if this looks like a good first step. Thanks!

jimmyjames avatar Jun 20 '17 14:06 jimmyjames

@jimmyjames I would love to see it be associated with the request vs. the response personally.

Schandlich avatar Jun 21 '17 16:06 Schandlich

Yeah @Schandlich I kind of agree. What about something like this, where there's a tooltip hint floated right of the operation (similar to Swagger UI):

image

jimmyjames avatar Jun 22 '17 19:06 jimmyjames

@jimmyjames I think the location is right. I would use a different icon though. Excited for this!

Schandlich avatar Jun 22 '17 19:06 Schandlich

@jimmyjames sorry for long reply!

This looks awesome. Proceed with PR please!

RomanHotsiy avatar Jun 22 '17 19:06 RomanHotsiy

@RomanGotsiy will do, need to move it from proof-of-concept to PR-worthy (me no Angular so well 😄 ). I used a ! since I didn't find any imgs in the project, wasn't sure if that was just because there hasn't been a need yet, or due to a design/performance consideration. I can either stick with that or try and find some type of padlock icon to use instead...

jimmyjames avatar Jun 22 '17 20:06 jimmyjames

Start with ! and then we will figure out how to add padlock icon in PR comments :)

RomanHotsiy avatar Jun 22 '17 20:06 RomanHotsiy

Having OAuth2 scopes for API calls is a highly requested feature for us too. I would love to see the scopes somewhere above call parameters listing, as this seems to be the best place for them: security

I'm ready to contribute to make ReDoc even better. I really love this tool!

bandantonio avatar Jul 25 '17 07:07 bandantonio

+1 this feature will be awesome! I can help too

jonyw4 avatar Aug 08 '17 19:08 jonyw4

+1 would really like this,

theholiday avatar Nov 21 '17 11:11 theholiday

+1 for sure!

serafimpinto avatar Nov 21 '17 22:11 serafimpinto

What is the status of this feature? Currently there is no way to see security at an operation leve.

robdefeo avatar Jan 09 '18 18:01 robdefeo

I think it's being worked on in version 2.

theholiday avatar Jan 10 '18 10:01 theholiday

as @theholiday mentioned this is being worked on in version 2. Here is the screenshot of the current implementation:

image

If anyone has a better idea of how to visualize this, please share here!

RomanHotsiy avatar Jan 21 '18 18:01 RomanHotsiy

I just noticed it's a dup of #7. Let's track this there. Closing this issue.

RomanHotsiy avatar Jan 21 '18 18:01 RomanHotsiy