XplMarcel
XplMarcel
Solved.. thanks
If an Authorize attribute on a Controller has Roles ( [Authorize(Roles = "MyRole"] ), the RolesAuthorizationRequirement gets added automatically to the defaultPolicy. Would it be possible to replace that requirement...
I agree that automatic auth middleware should be in place, but in this case it was in place since i was using Identity, where app.UseIdentity() clearly adds CookieAuthentication. So personally...
@dvdcrr77 I know how to add Requirements by name and use them in an Authorize attribute like [Authorize(policy = "tenant"). What i'm basicly looking for is a way to add...
@dvdcrr77 I think in this case that would be the only possible solution yeah. Maybe it would be a good idea for the future to support parameters on policies in...
Personally i think this is a bug. In my opinion a developer should be able to define his own Authorization policy (DefaultPolicy) using the Requirements he wants. All those requirements...
Eventually i solved the problem by deriving (like you proposed) from AuthorizeAttribute (basicly reintroducing it within my own namespace.) That way i can simply use the Authorize attribute with extended...
@dvdcrr77 I totally agree, but i didn't want to reinvent/rewrite the Authorization Middleware to suit my needs. ps.. i have no idea how to label an issue here.
@HaoK I was under the assumption that i could override the DefaultPolicy with the Requirements i need. ``` services.AddMvcCore() .AddAuthorization(options => { options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().AddRequirements(new TenantRequirement()).Build(); }) .AddFormatterMappings() .AddJsonFormatters()...
@blowdart That's what i was thinking with regards to the default policy, but i don't think requirements added to the default policy should be hard-coded in case developers want to...