Azure / Azure/azure-functions-openapi-extension
OAuth2 schema question
- 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
Assessment
This issue has not been assessed yet.