Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

[Exploratory Testing] Add Operation based extension methods/Overloads for the Authorization service and Options. #132

Closed
@harshgMSFT

Description

@harshgMSFT

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.

options.AddPolicy("ApiOperations", policyBuilder => policyBuilder.AddRequirement<Album>("Edit"));
OR
options.AddPolicy("ApiOperations", policyBuilder => policyBuilder.AddRequirement<Album>(new OperationRequirement { OpeartionKey = "Edit" }));

On calling Authorize on the Authorization service like so

_authorizationService.AuthorizeAsync("ApiOperations", context, album);

which finally calls into handler which has the following method

 public override Task<bool> CheckAsync<TResource, TRequirement>(AuthorizationContext context, TRequirement requirement)
        {     
        }

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions