casbin-net / casbin-aspnetcore

Casbin.NET integration middleware and sample code for ASP.NET Core
https://github.com/casbin/Casbin.NET
Apache License 2.0
64 stars 20 forks source link

Support for imperative authorization checks #42

Closed shayura closed 1 year ago

shayura commented 2 years ago

I have an application that uses imperative access control. In this application I cannot use attributes to enforce access to a controller action because the subject, object, and action needed to query the enforcer depend upon conditions that aren't available until much later.

Do you think this package already supports imperative authorization checks, e.g. using custom request transformers, or does it need an extra layer of code that's not there yet?

casbin-bot commented 2 years ago

@sagilio @xcaptain @huazhikui

VictorioBerra commented 2 years ago

You will need to roll your own AuthorizationHandler<T> and make a requirement that takes your conditions.

hsluoyz commented 2 years ago

@sagilio

sagilio commented 1 year ago

This feature already be supported, you can see some samples here: https://github.com/casbin-net/casbin-aspnetcore/blob/master/test/Casbin.AspNetCore.Tests/AuthorizationServiceTest.cs

We will provide more friendly APIs about this in future versions.

hsluoyz commented 1 year ago

@shayura

hsluoyz commented 1 year ago

Closed as resolved