Git Product home page Git Product logo

Comments (3)

zhiyuanliang-ms avatar zhiyuanliang-ms commented on June 1, 2024 1

It makes more sense to use resourse filter for the feature gate scenario. I will take a look at your PR and learn how to implement a filter attribute.

from featuremanagement-dotnet.

zhiyuanliang-ms avatar zhiyuanliang-ms commented on June 1, 2024

Hi, @WeihanLi

The Feature Management ASP.NET library provides FeatureGateAttribute and an extension method of AspNetCore.MVC.FilterCollection called AddForFeature which will add a FeatureGatedAsyncActionFilter.

Here what you pointed out is the FeatureGateAttribute which is built on ActionFilterAttribute.

The ASP.NET Core includes some built-in filter attributes:
ActionFilterAttribute
ExceptionFilterAttribute
ResultFilterAttribute
FormatFilterAttribute
ServiceFilterAttribute
TypeFilterAttribute

There is no built-in filter attributes for resource filter and authorization filter.

The way to use FeatureGateAttribute is to place it on MVC controllers, controller actions, or Razor pages.
The FeatureGateAttribute implements the OnActionExecutionAsync method which will [run before any of the action's filters]
(https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-8.0#controller-level-filters).

According to the diagram, it seems like the stage of "Model Binding" can be skipped. I don't think using AuthorizationFilter is sensible.

Therefore, it brings two questions:

  1. Should the stage of "Model Binding" be skipped?
  2. How to implement an Attribute for resource filter?

I need to do more investigation.

from featuremanagement-dotnet.

WeihanLi avatar WeihanLi commented on June 1, 2024

Thanks for the reply

  1. I think it should be skipped if the feature is not enabled, it seems no need to go through the model binding
  2. Need to inherit the Attribute to make it work as an attribute and implement the IResourceFilter/IAuthorizationFilter or/and the async interface ...

I tried to propose an AuthorizationFilterAttribute like the ActionFilterAttribute, but seemed the asp.net team does not want to include it in the framework dotnet/aspnetcore#40542

from featuremanagement-dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.