sustainsys-saml2

Is there a way to capture the LogIn event on SustainSys.Saml2


In an ASPNet Webapplication, we currently use Sustainsys.Saml2 for our authentication against Okta. This works well, however we would like to keep track of our users-login's inside the application.

So far we tried multiple eventhandlers HttpApplication.PostAuthenticateRequest, or the events on SessionAuthenticationModule but we cant seem to find the spot to capture the event.

Solution is ASP.Net MVC 5, with framework 4.7.2 and SustainSys.Saml2 1.0.2, with the Identitymodel implementation.

Any thoughts on this, apart from 'Upgrade' ?

TIA

I ended up with using the AcsCommandResultCreated.

For future reference, i added this to Application_Start :

// Capture the Login Event
Sustainsys.Saml2.Configuration.Options.FromConfiguration.Notifications
.AcsCommandResultCreated = (commandResult, response) =>
{
    var username = commandResult.Principal.FindFirst(c => c.Type == 
    ClaimTypes.NameIdentifier).Value;
    System.Diagnostics.Debug.Write($"{username} logged in at {DateTime.Now}");
};

Solution

  • Use the AcsCommandResultCreated notification. The name is maybe not that clear, but it is called right after the Saml2 message is validated and before the call to the ?SessionAuthenticationModule