【问题标题】:Where does HttpApplication.User.Identity get updated?HttpApplication.User.Identity 在哪里更新?
【发布时间】:2023-03-12 22:40:02
【问题描述】:

看似重复的问题,但没有详细回答。 好吧,至少我不相信。

Who sets the IsAuthenticated property of the HttpContext.User.Identity

答案是

FormsAuthentication.SetAuthCookie

但是我反编译了 System.Web.Security FormsAuthenication 类。 它调用 GetAuthCookie 并将其添加到响应中。

当找到 Session Cookie 而不是在 FormsAuthentication 中,如“正确答案”所述,我期待它出现在下一个请求中。 我搜索了完整的反编译源,但没有找到对 IPrincipal 的引用。 有人真的知道吗? 我可以用和 Event. 触发这个过程吗? 我注意到诸如

之类的事件
AuthenticateRequest

AuthorizeRequest

【问题讨论】:

    标签: asp.net-mvc forms-authentication security


    【解决方案1】:

    它是在事件AuthenticateRequest 中设置的,参见FormsAuthenticationModule.OnEnter,它被FormsAuthenticationModule.Init 绑定到AuthenticateRequest。如果想覆盖这个身份,你可以简单地自己设置HttpContext.User

    【讨论】:

    • 谢谢 Lukas,这就是我要找的 FormsAuthenticationModule。我将研究对 HttpContext.User 的直接访问
    猜你喜欢
    • 1970-01-01
    • 2012-12-01
    • 2015-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-20
    • 2014-02-08
    • 1970-01-01
    相关资源
    最近更新 更多