Search⌘ K

Configuring SSO Middleware in ASP.NET Core

Explore how to configure single sign-on middleware in ASP.NET Core applications, focusing on JWT bearer token authentication. Understand the setup process, library imports, and specific configurations needed for apps without user interfaces, such as headless APIs. Gain practical knowledge of authentication schemes, token validation, and middleware setup to secure your ASP.NET Core endpoints effectively.

While configuring any type of authentication and authorization middleware in ASP.NET Core requires the same basic principles to be applied, configuring SSO requires specific steps. The details also depend on whether the application to configure contains the UI that initiates the SSO flow or if it's a headless API that relies on another application to authenticate on its behalf.

We will examine how SSO is typically configured inside an ASP.NET Core application with the help of the playground below. This playground contains a headless web API application that accepts an access token from a client application that attempts to connect to it.

using Microsoft.AspNetCore.Mvc;

namespace DemoApp.Controllers;

[Route("api/[controller]")]
[ApiController]
public class InfoController : ControllerBase
{
    [HttpGet()]
    public IActionResult GetSecretInfo()
    {
        return Ok("Secret info delivered.");
    }
}
ASP.NET Core’s SSO setup demo

In this playground, we primarily focus on the ...