Fluent Security - configuring parameterized controller actions

馋奶兔 提交于 2019-12-01 20:21:29

问题


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();
}


来源:https://stackoverflow.com/questions/13203875/fluent-security-configuring-parameterized-controller-actions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!