331
CHAPTER 8 | Make secure .NET Microservices and Web Applications
If the user meets the requirement, a
call to
context.Succeed
will indicate that the user is authorized.
If there are multiple ways that a user might satisfy an authorization requirement, multiple handlers can
be created.
In addition to registering custom policy requirements with
AddPolicy
calls,
you also need to register
custom requirement handlers via Dependency Injection
(
services.AddTransient
()
).
An example of a custom authorization requirement and handler for checking a user’s age (base
d on a
DateOfBirth
claim) is available in the ASP.NET Core
authorization documentation
.
Dostları ilə paylaş: