policy-based authorization
Protecting endpoints with named policies that bundle requirements, such as a scope claim and a role.
In more detail
options.AddPolicy("catalog.write", p => p.RequireClaim("scope", "catalog.write")) defines one; RequireAuthorization("catalog.write") applies it. Keep policy names central so routes cannot misspell a permission.
Related terms
- authorization — Deciding whether an already identified caller may perform a particular action on a particular resource.
- claim — One statement inside a token, as a name and value, such as sub (subject), exp (expiry), iss (issuer), aud (audience) or scope.
- role — A coarse label on a user, such as editor or administrator, that authorization can check.
- scope claim — A token claim listing the permissions a client was granted, such as catalog.write.
Taught in
- Role-Based and Policy-Based Authorization — Modern .NET Core, C# & Enterprise Microservices