Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support authorization on operation level #561

Open
Kaliumhexacyanoferrat opened this issue Nov 21, 2024 · 0 comments
Open

Support authorization on operation level #561

Kaliumhexacyanoferrat opened this issue Nov 21, 2024 · 0 comments
Labels
enhancement New feature or request priority High-priority feature on our roadmap

Comments

@Kaliumhexacyanoferrat
Copy link
Owner

As a developer of a web service, I would like to control authorization on operation instead of API level, so that I do not need to handle the authorization within the operation and can simpliy annotate my methods.

Example

public class MyService 
{
    
    [ResourceMethod]
    [RequireAdmin]
    public IResponse AdminOnly() { ... }

}

public class RequireAdminAttribute : AuthorizeByAttribute<AdminAuthorization> { }

public class AdminAuthorization : IAuthorizationRule
{

    public ValueTask<bool> Authorize(IRequest request, OperationArguments arguments) 
    {
        // somehow include the attribute values
        return true; // maybe a more complex type, e.g. AuthorizationResult with Result features
    }

}

Acceptance criteria

  • The feature can be used on all frameworks
  • Authorization logic can easily fetch arguments passed to the operation by the client (typed)
  • Authorization logic can fetch arguments passed to the attribute
  • Authorization logic can return details to the client when access is denied (serialized in a default way)
  • The feature is documented on the GenHTTP website
  • The feature is covered by acceptance tests
@Kaliumhexacyanoferrat Kaliumhexacyanoferrat added enhancement New feature or request priority High-priority feature on our roadmap labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority High-priority feature on our roadmap
Projects
None yet
Development

No branches or pull requests

1 participant