-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Strawman for new authorization packages that can be shared between server and client #9997
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
Conversation
… server-side ASP.NET Core.
|
||
namespace Microsoft.AspNetCore.Authorization.Policy | ||
{ | ||
public class CommonPolicyEvaluator : ICommonPolicyEvaluator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need a PolicyEvaluator in the common layer? It was only introduced to tie authN + authZ together, I thought on the client side there's no authentication needed, so wouldn't the base IAuthorizationService
be sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do want to evaluate policies in client-side code.
I thought on the client side there's no authentication needed
That's not correct. Although authentication isn't enforced there (all true enforcement is server-side), we still want policies to exist as a way of informing the client about what the user is going to be allowed to do.
We seem to use Core everywhere, maybe Authorization.Core instead? |
Superseded by #10021. |
Our goal is that the same authorization attributes, DI services, and classes should be usable both in server-side ASP.NET Core (without any changes to customer code) and in client-side Blazor.
To make that possible, we have to introduce at least one new package where we can put things that should be common to both server and client. Restrictions include:
netstandard2.0
Http.Abstractions
(orHttpContext
in particular)This PR moves the majority of classes out of
Microsoft.AspNetCore.Authorization
and puts them in a new package,Microsoft.AspNetCore.Authorization.Common
. I'm not in any way in love with that name. I'm happy to call it anything else if someone has a preference. It just has to mean "authorization things that work both on the server and on the client".This shouldn't be a breaking change, since
Microsoft.AspNetCore.Authorization
now references the.Common
package, so all existing types continue to work (if you rebuild your app). I haven't set up actual type forwarders for people who reference things using reflection. Not sure if we would do that. I also haven't moved any tests since this is just a draft.Similarly I created
Microsoft.AspNetCore.Authorization.Common.Abstractions
to hold the two interfaces we need that used to be inHttp.Abstractions
.I haven't built anything end-to-end with this yet so don't even know if it meets our needs. Currently this is just seeking feedback on (a) the whole idea of moving all these things around, and (b) the package naming.