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

Provide an IAuthorizationFilter to filter accepted scopes #849

Closed
plamber opened this issue Dec 19, 2020 · 2 comments
Closed

Provide an IAuthorizationFilter to filter accepted scopes #849

plamber opened this issue Dec 19, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request fixed
Milestone

Comments

@plamber
Copy link

plamber commented Dec 19, 2020

Is your feature request related to a problem? Please describe.
The current version of microsoft-identity-web provides the ScopesRequiredHttpContextExtensions.VerifyUserHasAnyAcceptedScope(HttpContext, String[]) Method to verify that the user authenticated in the web API has any of the accepted scopes.

This method must be called in the API methods you are implementing. In some situations this is a repeating activity with repeating code.

Describe the solution you'd like
I wanted to improve the situation by providing an IAuthorizationFilter decorator for API classes and methods like this:
image

I ended up using the existing code implemented for VerifyUserHasAnyAcceptedScope and came with this Gist.

I am wondering if such a technique could become a part of the library. Personally, it feels more natural using the attributes as suggested here.

Describe alternatives you've considered
Implement it by my own

Additional context
Reference issue #65

@jmprieur
Copy link
Collaborator

jmprieur commented Jan 4, 2021

See in particular this comment (#65 (comment)) on how to return a custom error message

@jennyf19
Copy link
Collaborator

Included in 1.6.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed
Projects
None yet
Development

No branches or pull requests

3 participants