简体   繁体   English

动作筛选器+ AspNetRedisProvider

[英]Action Filters + AspNetRedisProvider

Hi i am currently implementing this provider " https://github.com/kylesonaty/AspNetRedisProviders " for an application i am currently working on in asp.net mvc4. 嗨,我目前正在为我当前在asp.net mvc4中工作的应用程序实现此提供程序“ https://github.com/kylesonaty/AspNetRedisProviders ”。 However things are not as rosy as i initially thought they would be. 但是,事情并没有我最初想象的那么乐观。 Since the providers are derived from respective abstract counterparts, I did like to know if the default authorize filters in asp.net mvc will still delegate calls to these providers 由于提供程序是从相应的抽象对应程序派生的,所以我想知道asp.net mvc中的默认授权过滤器是否仍将调用委托给这些提供程序

Thanks in advance 提前致谢

The default Authorization filter would provide some hooks to the Roles established by your custom provider. 默认的“授权”过滤器将为您的自定义提供程序建立的角色提供一些挂钩。 It is not directly, but indirectly. 它不是直接的,而是间接的。 For example, your role provider would set roles, and the Authorization attribute can be used to verify a particular role has been defined by the configured role provider. 例如,您的角色提供者将设置角色,并且Authorization属性可用于验证已配置的角色提供者已定义了特定角色。

 protected virtual bool AuthorizeCore(HttpContextBase httpContext)
 {
  if (httpContext == null)
    throw new ArgumentNullException("httpContext");
  IPrincipal user = httpContext.User;
  return user.Identity.IsAuthenticated 
   && (this._usersSplit.Length <= 0 ||
     Enumerable.Contains<string>((IEnumerable<string>) this._usersSplit, user.Identity.Name, (IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase)) 
   && (this._rolesSplit.Length <= 0 || Enumerable.Any<string>((IEnumerable<string>) 
     this._rolesSplit, new Func<string, bool>(user.IsInRole)));
  }

*this._rolesSplit, new Func(user.IsInRole)));* * this._rolesSplit,新Func(user.IsInRole)))*

For instance, the last line, this would check the role is valid for the current user, which has been set by the role provider. 例如,在最后一行,这将检查角色对当前用户是否有效(由角色提供者设置)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM