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

Support for scopes in scheme bearer #2407

Closed
vivas6 opened this issue Nov 12, 2020 · 6 comments
Closed

Support for scopes in scheme bearer #2407

vivas6 opened this issue Nov 12, 2020 · 6 comments

Comments

@vivas6
Copy link

vivas6 commented Nov 12, 2020

Hi,
JWT based access token (bearer) can contain scopes like read_pets, write_pets etc. that could be used to authorize an api request from an app. Why don't Open API spec talk about scopes for scheme: bearer? Shouldn't this be described in the spec as it is a widely used pattern for API authN & authZ?

e.g.

security:
        - bearerAuth: [read:pets, write:pets]

/Vineeth

@MikeRalphson
Copy link
Member

This will be supported in OAS 3.1. All securityScheme types may have scopes/roles in referring security requirement objects.

@unikitty37
Copy link

@MikeRalphson Were the docs updated to reflect this? The only likely thing I can find is under 4.8.30.1 Patterned Fields, which says "For other security scheme types, the array MAY contain a list of role names which are required for the execution, but are not otherwise defined or exchanged in-band." but doesn't give examples — all the examples are still for OAuth2 and that sentence seems to be all there is…

@MikeRalphson
Copy link
Member

Unfortunately we can't add examples of every combination of OAS feature. I'll add one here when I get back to my desk.

@unikitty37
Copy link

@MikeRalphson Sorry to hassle you, but did you manage to update the docs? I still can't find how to actually define my API's roles…

MikeRalphson added a commit to MikeRalphson/OpenAPI-Specification that referenced this issue Mar 31, 2021
@MikeRalphson
Copy link
Member

Not hassling at all, and sorry it has taken so long to get back to you. See an example in PR #2515

@unikitty37
Copy link

Thanks — I think I've been a little confused by what I thought this was going to be.

Basically, a logged-in user has a role of contributor, editor, or admin. A logged out user is treated as having the role of anonymous.

I was hoping this would allow me to say that an API call is only available with a role of editor or admin, but it seems that the Security Requirement Object still uses AND rather than OR. I appreciate the issue tracker probably isn't the best place for asking this, but is this possible with 3.1? If not, would it be worth making a feature request?

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

No branches or pull requests

3 participants