I've got a legacy Asp.Net/MVC/Razor WebApp that uses Forms authentication.
Now, because some users have an Azure AD account, I added a special AD SignIn button plus the usual code to make it work
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{...})
After the sign in using the button, I was getting in the following in the URL:
https://localhost:44361/Account/Index?ReturnUrl=%2fAccount%2fSignIn
Therefore in my Web.config I commented out:
<!--<authentication mode="Forms">
<forms loginUrl="~/Account/Index" timeout="2880" cookieless="UseDeviceProfile" />
</authentication>-->
At this stage Azure AD authentication works fine! But doing so, I broke the original Forms authentication :-(
Just calling
FormsAuthentication.SetAuthCookie(email, false);
is not enough: I'm still getting a redirection to Azure AD Signin page as soon as I call a controller with
[System.Web.Mvc.Authorize]
Plus I'm getting error messages because of
@Html.AntiForgeryToken()
A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' or 'http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider' was not present on the provided ClaimsIdentity. To enable anti-forgery token support with claims-based authentication, please verify that the configured claims provider is providing both of these claims on the ClaimsIdentity instances it generates. If the configured claims provider instead uses a different claim type as a unique identifier, it can be configured by setting the static property AntiForgeryConfig.UniqueClaimTypeIdentifier.
Can someone please tell me how to combine both authentication methods? Thank you!