在 Microsoft Katana 中,您如何找出某个键值对放在 Owin 上下文中的什么位置?

How do you find out where a certain key value pair was put inside the Owin context in Microsoft Katana?

我想找出哪段代码在 Owin 上下文中为键 "security.Authenticate" 设置了什么值。

我该怎么做?

我正在使用 Microsoft Katana 和 AspNet Identity。

背景

我已经阅读了 OAuth 2.0 规范,但我的目标是了解 Microsoft 如何在他们的代码中实现它。

因此,当您在 Visual Studio 2015 年打开带有 个人帐户 身份验证的 ASP.NET MVC 项目模板时,您会得到很多样板代码。

多年来,我已经学会了大部分内容,但时不时地,我会忘记并开始使用 Reflector 和 IL Spy 追查事情。

现在,我正在尝试了解样板附带的 ChallengeResult class 如何重定向到 OAuth 提供程序,而从其 ExecuteResult 它执行的方法。

我的研究使我找到了一行代码,它从 OwinContext 获取 func 并执行它。 funcOwinContext 中存储的密钥是​​ "security.Authenticate."

// Microsoft.Owin.Security.AuthenticationManager
internal Func<string[], 
        Action<IIdentity, 
        IDictionary<string, string>, 
        IDictionary<string, object>,  object>,
        object, 
        Task> AuthenticateDelegate
{
    get
    {
        return this._context
        .Get<Func<string[], 
        Action<IIdentity, IDictionary<string, string>, IDictionary<string, object>, object>, 
        object, Task>>("security.Authenticate");
    }
}

这个值在OwinRequestExtensions that is used in AuthenticationHandler. And after the long chain of calls, it ends up in CookieAuthenticationMiddleware和其他身份验证中间件中设置。