Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Definition and Assignment of OAuth Scopes #221

Description

I use OAuth 2.0 'password' and 'client_credentials' grant type to limit access to my API. For the sake of simplification, let's say we have two operations (i.e. API endpoints), where the first operation should be assigned with the scope 'read' and the second operation with the scope 'write'.

As far as I understand, I have to annotate the first operations with the following security tags:

///<security type="oauth2" name="oauth">
///     <description>...</description>
///     <scheme>bearer</scheme>
///     <bearerFormat>JWT</bearerFormat>
///     <flow type="password">
///         <authorizationUrl>...</authorizationUrl>
///         <tokenUrl>...</tokenUrl>
///          <scope name="read">
///               <description>...</description>
///          </scope>
///     </flow>
///     <flow type="clientCredentials">
///         <authorizationUrl>...</authorizationUrl>
///         <tokenUrl>...</tokenUrl>
///         <scope name="read">
///              <description>...</description>
///         </scope>
///     </flow>
///</security>
public void Operation1(...){...}

and the second operation with:

///<security type="oauth2" name="oauth">
///     <description>...</description>
///     <scheme>bearer</scheme>
///     <bearerFormat>JWT</bearerFormat>
///     <flow type="password">
///         <authorizationUrl>...</authorizationUrl>
///         <tokenUrl>...</tokenUrl>
///          <scope name="write">
///               <description>...</description>
///          </scope>
///     </flow>
///     <flow type="clientCredentials">
///         <authorizationUrl>...</authorizationUrl>
///         <tokenUrl>...</tokenUrl>
///         <scope name="write">
///              <description>...</description>
///         </scope>
///     </flow>
///</security>
public void Operation2(...){...}

However, the security declaration for the second operation is completely ignored.
Therefore, I assume that the security schema with all available scopes can only be defined once (but where?) and that there is another mechanism for assigning specific scopes to operations. Unfortunately, the wiki does not provide any example explaining the assignment of multiple scopes of the same security schema to multiple operations.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions