rufiooo
rufiooo

Reputation: 126

Resource based (Imperative) authorization won't enter the handler

Scenario:

I implemented resource based authorization inside my endpoint just like it's shown in microsoft documentation. It didn't work. I put a breakpoint inside my authorization handler and tried debugging, but when this handler should be called, it is not. I mean that when the following line runs

var authorizationResult = await _authorizationService
            .AuthorizeAsync(User, Document, "EditPolicy");

the Handler should be called, but that never happens.

Did anyone have the same problem?

Upvotes: 2

Views: 210

Answers (1)

rufiooo
rufiooo

Reputation: 126

So in the end the problem was due to the registration of the service in the startup.cs. I was using TryAddScope, by changing to AddScope it worked fine.

Upvotes: 1

Related Questions