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

[Bug] VerifyUserHasAnyAcceptedScope should throw UnauthorizedAccessException(message) (like roles) #389

Closed
7 tasks
jmprieur opened this issue Aug 2, 2020 · 1 comment
Assignees
Labels
bug Something isn't working fixed P1
Milestone

Comments

@jmprieur
Copy link
Collaborator

jmprieur commented Aug 2, 2020

Which version of Microsoft Identity Web are you using?
0.2.1-preview

Where is the issue?

  • Web app
    • Sign-in users
    • Sign-in users and call web APIs
  • Web API
    • [x ] Protected web APIs (validating tokens)
    • Protected web APIs (validating scopes)
    • Protected web APIs call downstream web APIs
  • Token cache serialization
    • In-memory caches
    • Session caches
    • Distributed caches
  • Other (please describe)

Repro

In tests\WebAppCallsWebApiCallsGraph\TodoListService\Controllers\TodoListController.cs, change line 22 to be

static readonly string[] scopeRequiredByApi = new string[] { "access_as_users" };

Runt the Web app and Web API

Expected behavior
The scope being invalid, the Web API should not process anything after calling HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi)

Actual behavior
The error is written in the HttpResponse, but the processing in the controller action continues

Possible solution
throw UnauthorizedAccessException(message) like what was done for roles in jennyf/roles for app roles

@jennyf19 : pre-assigning it to you as you've done the roles.

@jmprieur jmprieur added bug Something isn't working P1 labels Aug 2, 2020
@jmprieur jmprieur added this to the [3] Fundamentals milestone Aug 2, 2020
@jennyf19 jennyf19 added fixed and removed In progress labels Aug 4, 2020
@jennyf19
Copy link
Collaborator

jennyf19 commented Aug 7, 2020

Included in 0.2.2-preview release

@jennyf19 jennyf19 closed this as completed Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed P1
Projects
None yet
Development

No branches or pull requests

2 participants