Search⌘ K
AI Features

Configuring SSO in Blazor WebAssembly

Explore how to enable Single Sign-On in Blazor WebAssembly by configuring OIDC authentication without client secrets. Learn to implement login and logout flows, manage user authentication states, and integrate authentication UI components within the app layout.

In this lesson, we will learn how to enable SSO in a Blazor WebAssembly application. To demonstrate how it's done, we have the following playground:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}
Blazor WebAssembly app with the OpenID Connect flow

Note: Because we have to build two ASP.NET Core applications and populate the IdP database with the initial seed data, the build process is expected to take at least a few minutes.

This playground consists of the following two application projects:

  • DemoApp: This is the Blazor WebAssembly application.

  • OpenIddictAuthProvider: This is the IdP server application.

If we launch the application and wait for it to build, we will see the following home page:

Home page of a Blazor application
Home page of a Blazor application

When we click the "Log in" link in the top-right corner, we will be redirected to the IdP authentication page, where we can register a new user and log in. Because this environment is self-contained, any users registered in the previous lessons will no longer exist in the database. Therefore, we will have to register a new user upon ...