You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Today there is no simple way of registering requirements based on operations and then authorizing based on whether a particular user satisfies the requirement for an operation on a resource.
For instance, an admin(The identity) is allowed to edit (The operation based requirement) the price of an album (The resource).
The suggested experience should be something like :
This will add a policy called ApiOperations with an edit requirement on the Album resource.
This item needs more thought and design. Some of the other thoughts were to skip creation of the policy altogether and create it as an anonymous policy.
The text was updated successfully, but these errors were encountered:
public static class Operations {
public static OperationRequirement Edit = new OperationRequirement("Edit");
public static OperationRequirement Create = new OperationRequirement("Create");
public static OperationRequirement Delete = new OperationRequirement("Delete");
}
public class ExpenseReportAuthorizationHandler : AuthorizationHandler<OperationRequirement, ExpenseReport> {
public void HandleAsync(AuthorizationContext context, OperationRequirement req, ExpenseReport resource)
{
if (Repo.CanDo(req.Name, resource)) {
context.Succeed(req);
}
}
}
public class SuperUserHandler : AuthorizationHandler<OperationRequirement> {
public void HandleAsync(AuthorizationContext context, OperationRequirement req)
{
if (IsSuperUser(context.User) {
context.Succeed(req);
}
}
}
public class ExpenseReportService {
public ExpenseReportService(IAuthorizationService authService);
public void Approve(ExpenseReport report, ClaimsPrincipal user) {
if (!authService.Authorize(user, report, Operations.Approve)) {
throw new Exception("Unauthorized");
}
}
harshgMSFT
changed the title
[Resource based Authz] Add Operation based extension methods/Overloads for the Authorization service and Options.
[Exploratory Testing] Add Operation based extension methods/Overloads for the Authorization service and Options.
Jan 26, 2015
Today there is no simple way of registering requirements based on operations and then authorizing based on whether a particular user satisfies the requirement for an operation on a resource.
For instance, an admin(The identity) is allowed to edit (The operation based requirement) the price of an album (The resource).
The suggested experience should be something like :
This will add a policy called ApiOperations with an edit requirement on the Album resource.
On calling Authorize on the Authorization service like so
which finally calls into handler which has the following method
This item needs more thought and design. Some of the other thoughts were to skip creation of the policy altogether and create it as an anonymous policy.
The text was updated successfully, but these errors were encountered: