配置流畅安全时出错

时间:2016-05-08 18:31:31

标签: asp.net-mvc fluent-security

我已经在asp.net MVC5应用程序中的 FluentSecurity - Getting Started 中安装并配置了Fluentsecurity。但是当我忽略丢失的配置时,我收到错误。

错误消息是“ FluentSecurity.ConfigurationExpression不包含IgnoreMissingConfiguration的定义

SecurityConfigurator.Configure(configuration =>
        {
            // Let FluentSecurity know how to get the authentication status of the current user
            configuration.GetAuthenticationStatusFrom(() => HttpContext.Current.User.Identity.IsAuthenticated);

            // This is where you set up the policies you want FluentSecurity to enforce on your controllers and actions
            configuration.For<HomeController>().Ignore();
            configuration.For<AccountController>().DenyAuthenticatedAccess();
            //configuration.For<AccountController>(x => x.()).DenyAnonymousAccess();
            configuration.For<AccountController>(x => x.LogOff()).DenyAnonymousAccess();
            configuration.For<AccountController>(x => x.Login("")).Ignore();
            configuration.IgnoreMissingConfiguration();

            configuration.For<GuestsController>(x => x.Index()).Ignore();
            configuration.For<GuestsController>(x => x.Create()).RequireRole(BlogRole.Writer);
        });

我在这里想念的是什么?

1 个答案:

答案 0 :(得分:0)

网站上显示的示例与项目的当前版本(2.1.0)略有过时。 IgnoreMissingConfiguration方法在单独的类上定义,可通过Advanced属性访问。所以,改变这个:

configuration.IgnoreMissingConfiguration();

configuration.Advanced.IgnoreMissingConfiguration();