This is a string and can be anything. But this is an authentication type identifier. And you can have several types of authentication: your database with users, Google, Facebook, etc. As far as I remember, this is added as a claim to the generated cookie during registration.
You need to know the authentication provider when you sign up the user. If your authentication middleware is defined as follows:
app.UseCookieAuthentication(new CookieAuthenticationOptions { LoginPath = new PathString("/Login/"), AuthenticationType = "My-Magical-Authentication",
then for the userโs signature you will need the same magic line: AuthenticationManager.SignOut("My-Magical-Authentication")
This string is also passed to ClaimsIdentity
when the principal is created. And without AuthenticationType
principal cannot be authenticated because :
/// <summary> /// Gets a value that indicates whether the identity has been authenticated. /// </summary> /// /// <returns> /// true if the identity has been authenticated; otherwise, false. /// </returns> public virtual bool IsAuthenticated { get { return !string.IsNullOrEmpty(this.m_authenticationType); } }
This IsAuthenticated
method IsAuthenticated
used across the entire MVC codebase, with all authentication mechanisms relying on this.
Also, theoretically, you can log in through several providers and simultaneously release only one of them, leaving the remaining providers still authenticated. Although I have never tried this.
Another use I just found is if you do not provide CookieName
in the middleware configuration, then Options.CookieName = CookieAuthenticationDefaults.CookiePrefix + Options.AuthenticationType;
( see the second if statement in the constructor ).
I am sure there are more places where it is used. But the most important thing is to ensure it and match the name, or you will get subtle errors in the authentication system.