Repository navigation
Authorization middleware - #1894
Conversation
|
Although the logic in the authz middleware is very similar to the authz filter, they are different. For example, how each gets the policy, how each denies unauthorized requests. I don't think there is anything to share between them that not is already shared. |
|
Code looks fine, do we want consider just having this live in the Authorization.Policy package that the evaluator lives in? There isn't very much in that package today, and since this middleware depends on that, it doesn't seem like a terrible fit... |
|
I chose not to because Authorization.Policy has no dependency on Http, and the namespace for every file is Authorization.Policy. It feels like an odd fit to put middleware in it. |
|
It does though since I created it basically to be able to use Authorization and Http together, the reason you don't see http in the namespaces, is due to authentication not having it even though its lives in httpabstractions: Also for example, the main PolicyEvaluator AuthenticateAsync method takes httpContext as a parameter: |
|
Ah ok. I didn't follow down the transitive dependencies. That makes me feel better about it. I still think it is an odd fit but happy to be outvoted. Its not a hill I'll die on 😄 |
|
I'll read through this tomorrow, but I do want you to try to replace this sample as an acceptance test. |
c6dfc55 to
ddc27a5
Compare
|
🆙 📅 The remaining ask is a policy that runs even if there is no endpoint matched, or there is no Authorization today has the concept of What about adding the idea of Questions:
Alternative suggestions welcome! |
|
Just to clarify the meaning of GlobalPolicy, this is basically a required policy that always must be satisfied, as compared to DefaultPolicy which is only used if no policy is specified... If that's the case I think I prefer a name closer to RequiredPolicy since its always applied no matter what? |
|
Also if we want to introduce something like this, maybe it would make more sense to bake in at the lowest level so imperative calls to IAuthorizationService.Authorize would pick it up as well, instead of something that only middleware/endpoints could take advantage of (this would align with exposing it in AuthorizationOptions) |
|
Basically the default authZ service implementation would just always include the requirements from the Global/Required policy in addition to any other requirements passed in for evaluation. |
Ok!
Good idea! I think it would feel cleanest if it was exposed from IAuthorizationPolicyProvider: |
|
That's what major versions changes are for :) Yeah I agree it should just behave just like DefaultPolicy so it should get a method on the policy provider and we can just have the default policy provider read it from the options just like with the default policy. |
|
Updated with RequiredPolicy + tests. |
|
@natemcmaster @ryanbrandenburg Hi. Could one of y'all enable feature branch builds for https://dotnet.myget.org/feed/aspnetcore-dev/package/nuget/Microsoft.AspNetCore.Authorization.Policy ? I'd like to use a package over here: https://github.com/aspnet/AuthSamples |
done |
|
Two open questions to resolve:
I don't have a strong opinion either way about adding or removing these. |
|
If you don't need either of these anymore, maybe leaving them out to start is best. |
|
🆙 📅 |
https://github.com/aspnet/Routing/issues/537
Will add tests in a different PR