We register AuthenticationScheme and SAML2Options in startup.cs (.net6 project). During the registration, we set ForceAuthentication = false because the IDP we integrate with has a different login screen for e-sign.
We have to set ForceAuthentication = true only when we request an e-signature.
Our work flow is
I finally found the answer. AuthenticationRequestCreated method will be called when user goes through the authentication Challenge
saml2options.Notifications.AuthenticationRequestCreated = AuthenticationRequestCreated;
private void AuthenticationRequestCreated(Saml2AuthenticationRequest request, IdentityProvider idp, IDictionary<string, string> dict)
{
dict.TryGetValue("returnUrl", out string returnValue);
if (returnValue.Contains("e-signature"))
{
request.ForceAuthentication = true;
}else
{
request.ForceAuthentication = false;
}
}