RoleManagerModule 和 RolePrincipal 对象
根据我的书,如果启用了角色管理,则 RoleManagerModule
通过将 RolePrincipal
对象分配给 HttpRequest.User
来创建用户的安全上下文。 但是,安全上下文是否已由 FormsAuthenticationModule
创建(因此主体对象被分配给 HttpContext.User
),该安全上下文在 RoleManagerModule
之前被调用叫?
我问这个问题是因为在下面的代码中分配给 HttpRequest.User 的主体对象已经存在,即使尚未调用 RoleManagerModule :
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated && Roles.Enabled)
{
//here we subscribe user to a role via Roles.AddUserToRole()
}
}
主体对象也是如此由 FormsAuthenticationModule
分配给 HttpRequest.User
,然后替换为 RolePrincipal
对象(由 RoleManagerModule
创建)?
According to my book, if role management is enabled, then RoleManagerModule
creates the security context of the user by assigning RolePrincipal
object to the HttpRequest.User
. But isn’t security context already created (thus principal object being assigned to HttpContext.User
) by FormsAuthenticationModule
, which is called prior to RoleManagerModule
being called?
I’m asking this, because in the following code principal object assigned to HttpRequest.User
already exists, even though RoleManagerModule
has not yet been called:
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated && Roles.Enabled)
{
//here we subscribe user to a role via Roles.AddUserToRole()
}
}
So is principal object, created by FormsAuthenticationModule
and assigned to HttpRequest.User
, later replaced by RolePrincipal
object (created by RoleManagerModule
)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这篇文章:
所以你是对的。
According to this article:
So you're right.