Sustainsys / Saml2

Saml2 Authentication services for ASP.NET
Other
960 stars 603 forks source link

(Question) How to log incoming SamlResponse in .Net Core 3.1 #1296

Closed telalwar closed 2 years ago

telalwar commented 3 years ago

I'm chasing, - MVC Exception Handler: IDX10214: Audience validation failed. Audiences: '[PII is hidden. For more details, see https this error, this error clearly states that Audience was not matched.

  1. I verified that (IDP) client added correct audience information on their end.

  2. To further debug, I want to print full incoming SamlResponse where I can see the incoming Audience info.

As per suggestion in this issue, https://github.com/Sustainsys/Saml2/issues/1030 we have our own implementation of GetExternalLoginInfoAsync. Mostly i'm interested to see Audience value incoming saml response

 public override async Task<ExternalLoginInfo> GetExternalLoginInfoAsync(string expectedXsrf = null)
 {
          var auth = await Context.AuthenticateAsync(IdentityConstants.ExternalScheme);
          string providerKey = auth.Principal.FindFirstValue(ClaimTypes.NameIdentifier);

          // HERE I want to log full incoming SamlResponse

          .....
            return new ExternalLoginInfo(auth.Principal, "SAML", providerKey, "SAML")
                {
                    AuthenticationTokens = auth.Properties.GetTokens(),
                    AuthenticationProperties = auth.Properties
                };
 }