Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SustainSys.Saml2 on ASP.NET Core 2 - GetExternalLoginInfoAsync() returns null

I'm integrating SustainSys.Saml2, with Gluu server as my IdP. I'm using the scaffolded Identity pages out of the box. When I run in localhost, and I view the console log everything seems to work with the SAML communication, and I even see a couple lines that read:

Sustainsys.Saml2.AspNetCore2.Saml2Handler[0]
Successfully processed SAML response Microsoft.IdentityModel.Tokens.Saml2.Saml2Id and authenticated
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler[10]
AuthenticationScheme: Identity.External signed in.

Unless I'm mistaken, that indicates everything's good on the SAML end of things. But what I don't then understand is why, in ExternalLogin.OnGetCallbackAsync, the command

var info = await _signInManager.GetExternalLoginInfoAsync();

finds info set to null.

For the record, in Startup.cs, I have:

services.AddAuthentication()
  .AddSaml2(options =>
  {
    options.SPOptions.EntityId = new EntityId("{entityId}");
    options.IdentityProviders.Add(
      new IdentityProvider(new EntityId("{entityId}"), options.SPOptions)
      {
        Metadatalocation = "{metadataURL}",
      });
    options.Validate();
  });
like image 336
David Avatar asked Mar 11 '19 05:03

David


1 Answers

I was able to figure this out based on this GitHub issue, and Anders' notes in there.

I'll link to my comment there. Read Anders' comment above that for explanation. https://github.com/Sustainsys/Saml2/issues/1030#issuecomment-616842796

like image 55
ChiefMcFrank Avatar answered Oct 02 '22 15:10

ChiefMcFrank