-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[REQ] Add Authorize and bearer roles/scopes support to aspnetcore #1983
Comments
@MBcom I'm trying to implement Role based authorization via the
Can you point me towards a working example for a bearer security schema with scopes? I also found this related PR but the conversation is not clear whether the |
@tmakin you can add the needed scopes in the security part of each route as an array delete:
summary: Remove a sth
operationId: removeSth
security:
- bearerAuth: #<- the name of your security scheme
- scope1
- scope2
.... this should generate the following annotated route [HttpDelete]
[Route("/api/v1/example")]
[Authorize(Roles = "scope1,scope2")]
[ValidateModelState]
[SwaggerOperation("removeSth")]
public virtual IActionResult RemoveSth() ... I did not tested it again with upstream version - so let me know if you are experiencing any errors |
Thanks @MBcom . That's the pattern I was following but I'm not seeing anything inside the |
For the record, I've gone with a vendor extension based approach for this instead. It seems more compliant with the OpenAPI spec and also better for documentation generation.
Note that |
@tmakin maybe it is a solution too |
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
[Authorize]
Annotation for each route[Authorize(Roles = "...")]
Describe alternatives you've considered
Additional context
see the linked pull request for my suggestions
The text was updated successfully, but these errors were encountered: