Fluent Security-配置参数化的控制器操作 [英] Fluent Security - configuring parameterized controller actions

查看:82
本文介绍了Fluent Security-配置参数化的控制器操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了大量研究,并且已经测试了FluentSecurity库的1.4和2.0版本,但我似乎无法使用配置模式:

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?

推荐答案

我在问同样的问题.当前,您可以传递参数的默认值.

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

其中HomeController是:

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

这篇关于Fluent Security-配置参数化的控制器操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆