liveBook · Manning

Chapter 8: Application security in Aspire

What you will learn in chapter 8 of Building Distributed Applications that Work

The chapter introduction explains why publicly accessible Aspire applications need security, why the approach is not tied to one identity provider, and why the dashboard needs separate protection.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduction explains why publicly accessible Aspire applications need security, why the approach is not tied to one identity provider, and why the dashboard needs separate protection.

Key terms: authorized users, Aspire, orchestrated application, authentication provider, authentication and authorization protocols, fixed endpoint, Keycloak, Aspire dashboard, internal logs, separate mechanism

8.1 A brief introduction to single sign-on

Introduces single sign-on, its identity-provider and token flow, and why authentication matters for the online shop.

Key terms: single sign-on (SSO), identity provider (IdP), IdP, token, redirect, browser cookie, OpenID Connect (OIDC), OAuth, authentication, authorization

8.2 Using service discovery in SSO

This section explains how Aspire supplies the addresses needed for OIDC single sign-on, including local redirect URLs and service-discovered communication with the identity provider.

Key terms: SSO, OIDC, IdP, redirect address, HTTPS endpoint, HTTP endpoint, WEBAPP_HTTP_CONTAINERHOST, Keycloak container realm import, local development environment, unsecured HTTP endpoint

8.3 Enforcing UI authentication

This section explains how the OnlineShop.Web UI configures cookie and OIDC authentication and restricts an order-tracking page to authenticated users.

Key terms: AddAuthentication(), DefaultScheme, DefaultChallengeScheme, AddCookie(), AddOpenIdConnect(), Backchannel, Authority, ClientId, ClientSecret, IdP

8.3.1 Partially enforcing security

This section makes order controls conditional on authentication, connects the Blazor frontend to sign-in, and identifies the limit of frontend-only protection.

Key terms: AuthorizeView, Authorized, NotAuthorized, Sign in to order, CascadingAuthenticationState, Routes.razor, sign-in and sign-out endpoints, SSO middleware, IdP, frontend

8.4 Enforcing API authentication

This section explains how OnlineShop.ApiService validates JWTs on incoming requests and requires authorization for its order placement endpoint.

Key terms: OnlineShop.ApiService, JSON Web Token (JWT), authentication scheme, Authority, IdP, ValidateAudience, TokenValidationParameters, Audience (aud), authorization components, authentication and authorization middleware

8.4.1 Passing a JWT to the API

This subsection shows how the web UI forwards a logged-in user’s access token to the backend API as a bearer token.

Key terms: ProductsApiClient, authentication state, access token, authorization header, Bearer

8.5 Securing the Aspire dashboard

This section explains how to choose an authentication mode for the Aspire dashboard and how its default browser-token access works.

Key terms: Dashboard, Frontend, AuthMode, appsettings.json, Unsecured, BrowserToken, dotnet run, access token, OpenIdConnect, OIDC

8.6 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 7: Components for messaging and caching Chapter 9: Deploying Aspire apps to production →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.