Azure / Azure/azure-functions-openapi-extension

OAuth2 schema question

Open
#129 0 comments 0 reactions 0 assignees View on GitHub
Needs: Triage (Functions)
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am working on OAuth2 flow and API Schema decoration. I have one question about it.

OpenApiOAuthSecurityFlows has Scopes property where you can provide multiple scopes.

` public class OAuthSecurityFlow : OpenApiOAuthSecurityFlows
{
public OAuthSecurityFlow()
{
AuthorizationCode = new OpenApiOAuthFlow()
{
AuthorizationUrl = new Uri(Environment.GetEnvironmentVariable("OAuthAuthorizationUrl")),
TokenUrl = new Uri(Environment.GetEnvironmentVariable("OAuthTokenUrl")),
Scopes = { { "API.Read", "Read access" }, { "API.Write", "Write access" } }
};
}
}`

Then you can use this flow together with the OpenApiSecurity attribute.

The case is:
- GET API endpoint requires API.Read scope,
- POST API endpoint requires API.Write scope.

Both scopes were defined in the XYZ security flow.

Is there a way to define the specific scope required for the endpoint? Using one security flow definition but with selected scopes per endpoint?

At this moment we will get both scopes: API.Read, API.Write under GET and POST endpoints.

`"get": {
"tags": [
"GET"
],
"operationId": "Get",
...
"security": [
{
"xyz": [
"API.Read",
"API.Write"
]
}
]
}
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.