I'd like to find out which piece of code put what value for the key "security.Authenticate" in the Owin
context.
How do I do that?
I am using Microsoft Katana with AspNet Identity.
Background
I've read the OAuth 2.0 specification but my goal is to find out how Microsoft implements it in their code.
So, when you open an ASP.NET MVC project template with Individual Accounts authentication in Visual Studio 2015, you get a lot of boiler plate code.
Over the years, I have learn to understand most of it, but every now and then, I'll forget and start chasing things down using Reflector and IL Spy.
Right now, I am trying to understand how the ChallengeResult
class that comes in with the boilerplate redirects to the OAuth provider when it doesn't at all seem apparent looking at its ExecuteResult
method that it does.
My research led me to a line of code that gets a func
from the OwinContext
and executes it. The key that the func
was stored with in the OwinContext
was "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");
}
}
This value is set in OwinRequestExtensions that is used in AuthenticationHandler. And after the long chain of calls, it ends up in CookieAuthenticationMiddleware and other authentication middlewares.