Fluent Security - configuring parameterized contro

2019-02-24 18:09发布

问题:

I have done quite a bit of research and have tested both the 1.4 and 2.0 versions of the FluentSecurity libraries and I don't seem to be able to use the configuration pattern:

configuration.For<MyController>(x => x.GetCustomer())
  .RequireRole(appRoles);

when my controller action requires a parameter such as:

public ActionResult GetCustomer(int customerID)

Is this type of configuration currently supported? If so, how do I implement a role requirement against an action that has a required parameter?

回答1:

I was asking the same question. Currently, you can pass in default values for the parameters.

configuration
    .For<HomeController>(x => x.Index(default(string)))
    .DenyAnonymousAccess();

where HomeController is:

public ActionResult Index(string id)
{
    return View();
}