Is it possible to add a new Security Policy in .NET without recompiling?

40 views Asked by At

If I need to add new test to a policy-based security configuration, MS says to add a new condition or the like to my handler or create another handler.

https://learn.microsoft.com/en-us/aspnet/core/security/authorization/policies

services.AddAuthorization(options =>
{
    options.AddPolicy("BadgeEntry", policy =>
        policy.RequireAssertion(context =>
            context.User.HasClaim(c =>
                (c.Type == ClaimTypes.BadgeId ||
                 c.Type == ClaimTypes.TemporaryBadgeId) &&
                 c.Issuer == "https://microsoftsecurity")));
});

I am trying to avoid having to recompile everytime I need a new exception or a new policy needs to be added. That seems to me to be just as tightly coupled as adding a new role to an attribute everytime something new pops up. Add a new role to my attribute, recompile.

Is it possible to add a new Security Policy in .NET without recompiling?

(I have read this, Can Policy Based Authorization be more dynamic?)

0

There are 0 answers