azureidentityserver4samlsustainsys-saml2

Cannot Logout from IdentityServer 4 through Azure SAML logout request


Context

I have a Service Provider (SP) based on IdentityServer 4 and Sustainsys.Saml2.AspNetCore2 that is configured to use Azure as an IdP (SAML2). I also have a SPA with an api that connects to my SP (with oidp) to identify my user. The api then creates a JWT for my user to use.

I can login my user correctly.

Question

My issue comes with the logout. I want to use the logout url parameter of Azure to notify my SP about the logout. I manage to see the SAML Logout Request as a string when I configure an endpoint of mine but I can't exploit it and parsing it manually does't seem right.

Is there an existing endpoint that would come with my dependencies that I missed? The goal here is to revoke all my user's application sessions (the apps to which my user is connected throug my SP).

Configuration

Idp configuration in the SP (called in Startup.cs). The Saml2AuthModel comes from a config file.

 public static AuthenticationBuilder AddSaml2Auth(this AuthenticationBuilder builder, Saml2AuthModel saml2AuthModel)
  {
     builder.AddSaml2(saml2AuthModel.Scheme, saml2AuthModel.DisplayName ?? saml2AuthModel.Scheme, options =>
     {
        options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
        options.SignOutScheme = IdentityServerConstants.SignoutScheme;

        options.SPOptions.EntityId = new EntityId(saml2AuthModel.ServiceProviderEntityId);

        options.SPOptions.ModulePath = "/" + saml2AuthModel.ModulePath ?? saml2AuthModel.Scheme ?? options.SPOptions.ModulePath;

        var idp = new IdentityProvider(
           new EntityId(saml2AuthModel.IdentityProviderEntityId),
           options.SPOptions
        );

        idp.MetadataLocation = saml2AuthModel.IdentityProviderMetadataLocation;

        options.IdentityProviders.Add(idp);
     });

     return builder;
  }

Solution

  • The Sustainsys.Saml2 library has support for single logout. To enable it, you need to set up a service signing key. The reason is that logout requests and responses should be signed. So the library doesn't expose the logout endpoints if it has no signing keys available.