Skip to content

Commit f7aebe1

Browse files
committed
Updates
1 parent 42e6cc3 commit f7aebe1

3 files changed

Lines changed: 39 additions & 37 deletions

File tree

aspnetcore/blazor/security/blazor-web-app-with-entra.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ zone_pivot_groups: blazor-web-app-entra-specification
1919

2020
This article describes how to secure a Blazor Web App with [Microsoft identity platform](/entra/identity-platform/)/[Microsoft Identity Web packages](/entra/msal/dotnet/microsoft-identity-web/) for [Microsoft Entra ID](https://www.microsoft.com/security/business/microsoft-entra) using a sample app.
2121

22-
:::zone pivot="without-bff-pattern"
22+
:::zone pivot="non-bff-pattern"
2323

24-
This version of the article covers implementing Entra without adopting the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends). The BFF pattern is useful for making authenticated requests to external services. Change the article version selector to **Entra with BFF pattern** if the app's specification calls for adopting the BFF pattern.
24+
This version of the article covers implementing Entra without adopting the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends). The BFF pattern is useful for making authenticated requests to external services. Change the article version selector to **BFF pattern** if the app's specification calls for adopting the BFF pattern.
2525

2626
The following specification is covered:
2727

@@ -40,7 +40,7 @@ The sample app consists of two projects:
4040
* `BlazorWebAppEntra`: Server-side project of the Blazor Web App, containing an example [Minimal API](xref:fundamentals/minimal-apis) endpoint for weather data.
4141
* `BlazorWebAppEntra.Client`: Client-side project of the Blazor Web App.
4242

43-
Access sample apps through the latest version folder from the repository's root with the following link. The projects are in the `BlazorWebAppEntra` folder for .NET 9 or later.
43+
Access the sample through the latest version folder in the Blazor samples repository with the following link. The sample is in the `BlazorWebAppEntra` folder for .NET 9 or later.
4444

4545
[View or download sample code](https://github.com/dotnet/blazor-samples) ([how to download](xref:blazor/fundamentals/index#sample-apps))
4646

@@ -100,17 +100,17 @@ Example:
100100

101101
:::zone-end
102102

103-
:::zone pivot="with-bff-pattern"
103+
:::zone pivot="bff-pattern"
104104

105-
This version of the article covers implementing Entra with the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends). Change the article version selector to **Entra without BFF pattern** if the app's specification doesn't call for adopting the BFF pattern.
105+
This version of the article covers implementing Entra with the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends). Change the article version selector to **Non-BFF pattern** if the app's specification doesn't call for adopting the BFF pattern.
106106

107107
The following specification is covered:
108108

109109
* The Blazor Web App uses the [Auto render mode with global interactivity (`InteractiveAuto`)](xref:blazor/components/render-modes).
110110
* The server project calls <xref:Microsoft.Extensions.DependencyInjection.WebAssemblyRazorComponentsBuilderExtensions.AddAuthenticationStateSerialization%2A> to add a server-side authentication state provider that uses <xref:Microsoft.AspNetCore.Components.PersistentComponentState> to flow the authentication state to the client. The client calls <xref:Microsoft.Extensions.DependencyInjection.WebAssemblyAuthenticationServiceCollectionExtensions.AddAuthenticationStateDeserialization%2A> to deserialize and use the authentication state passed by the server. The authentication state is fixed for the lifetime of the WebAssembly application.
111111
* The app uses [Microsoft Entra ID](https://www.microsoft.com/security/business/microsoft-entra), based on [Microsoft Identity Web](/entra/msal/dotnet/microsoft-identity-web/) packages.
112112
* Automatic non-interactive token refresh is managed by the framework.
113-
* The app uses server-side and client-side service abstractions to display generated weather data:
113+
* The app uses server-side and client-side service abstractions to display generated weather data.
114114
* The [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends) is adopted using [.NET Aspire](/dotnet/aspire/get-started/aspire-overview) for service discovery and [YARP](https://dotnet.github.io/yarp/) for proxying requests to a weather forecast endpoint on the backend app.
115115
* A backend web API uses JWT-bearer authentication to validate JWT tokens saved by the Blazor Web App in the sign-in cookie.
116116
* Aspire improves the experience of building .NET cloud-native apps. It provides a consistent, opinionated set of tools and patterns for building and running distributed apps.
@@ -135,7 +135,7 @@ The sample app consists of five projects:
135135
* `BlazorWebAppEntra`: Server-side project of the Blazor Web App.
136136
* `BlazorWebAppEntra.Client`: Client-side project of the Blazor Web App.
137137

138-
Access sample apps through the latest version folder from the repository's root with the following link. The projects are in the `BlazorWebAppEntraBff` folder for .NET 9 or later.
138+
Access the sample through the latest version folder in the Blazor samples repository with the following link. The sample is in the `BlazorWebAppEntraBff` folder for .NET 9 or later.
139139

140140
[View or download sample code](https://github.com/dotnet/blazor-samples) ([how to download](xref:blazor/fundamentals/index#sample-apps))
141141

@@ -163,7 +163,7 @@ The `MinimalApiJwt` project is a backend web API for multiple frontend projects.
163163

164164
The `MinimalApiJwt.http` file can be used for testing the weather data request. Note that the `MinimalApiJwt` project must be running to test the endpoint, and the endpoint is hardcoded into the file. For more information, see <xref:test/http-files>.
165165

166-
Secure weather forecast data endpoint in the project's `Program` file:
166+
A secure weather forecast data endpoint in the project's `Program` file:
167167

168168
```csharp
169169
app.MapGet("/weather-forecast", () =>
@@ -188,7 +188,9 @@ This section explains how to configure the sample app.
188188

189189
<xref:Microsoft.Identity.Web.AppBuilderExtension.AddMicrosoftIdentityWebApp%2A> from [Microsoft Identity Web](/entra/msal/dotnet/microsoft-identity-web/) ([`Microsoft.Identity.Web` NuGet package](https://www.nuget.org/packages/Microsoft.Identity.Web), [API documentation](<xref:Microsoft.Identity.Web?displayProperty=fullName>)) is configured by the `AzureAd` section of the server project's `appsettings.json` file.
190190

191-
In the app's registration in the Entra or Azure portal, use a **Web** platform configuration with a **Redirect URI** of `https://localhost/signin-oidc` (a port isn't required). Confirm that **ID tokens** and access tokens under **Implicit grant and hybrid flows** are **not** selected. The OpenID Connect handler automatically requests the appropriate tokens using the code returned from the authorization endpoint. The `Weather.Get` scope is configured in the Azure or Entra portal in **Expose an API**. In **API Permissions**, grant delegated permission with Admin consent to access to the **BlazorWebAppEntra** > **Weather.Get** API.
191+
In the app's registration in the Entra or Azure portal, use a **Web** platform configuration with a **Redirect URI** of `https://localhost/signin-oidc` (a port isn't required). Confirm that **ID tokens** and access tokens under **Implicit grant and hybrid flows** are **not** selected. The OpenID Connect handler automatically requests the appropriate tokens using the code returned from the authorization endpoint.
192+
193+
The `Weather.Get` scope is configured in the Entra or Azure portal in **Expose an API**. Do ***not*** configure **API Permissions** (grant delegated permission) to access weather data via the web API.
192194

193195
### Configure the server project
194196

@@ -253,7 +255,7 @@ If you don't add the signed-out callback path URI to the app's registration in E
253255
254256
[!INCLUDE[](~/blazor/security/includes/secure-authentication-flows.md)]
255257

256-
:::zone pivot="with-bff-pattern"
258+
:::zone pivot="bff-pattern"
257259

258260
### Configure the backend web API project (`MinimalApiJwt`)
259261

@@ -267,7 +269,7 @@ Configure the project in the <xref:Microsoft.AspNetCore.Authentication.JwtBearer
267269
jwtOptions.Authority = "{AUTHORITY}";
268270
```
269271

270-
The following example use a Tenant ID of `aaaabbbb-0000-cccc-1111-dddd2222eeee`.
272+
The following examples use a Tenant ID of `aaaabbbb-0000-cccc-1111-dddd2222eeee`.
271273

272274
If the app is registered in an ME-ID tenant, the authority should match the issurer (`iss`) of the JWT returned by the identity provider:
273275

@@ -289,7 +291,7 @@ jwtOptions.Authority = "https://login.microsoftonline.com/aaaabbbb-0000-cccc-111
289291
jwtOptions.Audience = "{AUDIENCE}";
290292
```
291293

292-
Match the value to just the path of the **Application ID URI** configured when adding the `Weather.Get` scope under **Expose an API** in the Azure or Entra portal.
294+
Match the value to just the path of the **Application ID URI** configured when adding the `Weather.Get` scope under **Expose an API** in the Entra or Azure portal.
293295

294296
The following examples use an Application (Client) Id (`{CLIENT ID}`) of `00001111-aaaa-2222-bbbb-3333cccc4444`. The second example uses a directory name (`{DIRECTORY NAME}`) of `contoso`.
295297

@@ -445,13 +447,13 @@ Alternatively, use the following `LogInOrOut` component, which doesn't supply a
445447
<AntiforgeryToken />
446448
<button type="submit" class="nav-link">
447449
<span class="bi bi-arrow-bar-left-nav-menu" aria-hidden="true">
448-
</span> Logout @context.User.Identity?.Name
450+
</span> Logout
449451
</button>
450452
</form>
451453
</Authorized>
452454
<NotAuthorized>
453455
<a class="nav-link" href="authentication/login">
454-
<span class="bi bi-person-badge-nav-menu" aria-hidden="true"></span>
456+
<span class="bi bi-person-badge-nav-menu" aria-hidden="true"></span>
455457
Login
456458
</a>
457459
</NotAuthorized>

aspnetcore/blazor/security/blazor-web-app-with-oidc.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ zone_pivot_groups: blazor-web-app-oidc-specification
1515

1616
This article describes how to secure a Blazor Web App with [OpenID Connect (OIDC)](https://openid.net/developers/how-connect-works/) using a sample app in the [`dotnet/blazor-samples` GitHub repository (.NET 8 or later)](https://github.com/dotnet/blazor-samples) ([how to download](xref:blazor/fundamentals/index#sample-apps)).
1717

18-
:::zone pivot="without-bff-pattern"
18+
:::zone pivot="non-bff-pattern"
1919

20-
This version of the article covers implementing OIDC without adopting the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends) with an app that adopts global Interactive Auto rendering (server and `.Client` projects). The BFF pattern is useful for making authenticated requests to external services. Change the article version selector to **OIDC with BFF pattern** if the app's specification calls for adopting the BFF pattern.
20+
This version of the article covers implementing OIDC without adopting the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends) with an app that adopts global Interactive Auto rendering (server and `.Client` projects). The BFF pattern is useful for making authenticated requests to external services. Change the article version selector to **BFF pattern** if the app's specification calls for adopting the BFF pattern.
2121

2222
The following specification is covered:
2323

@@ -36,7 +36,7 @@ The sample app consists of two projects:
3636
* `BlazorWebAppOidc`: Server-side project of the Blazor Web App, containing an example [Minimal API](xref:fundamentals/minimal-apis) endpoint for weather data.
3737
* `BlazorWebAppOidc.Client`: Client-side project of the Blazor Web App.
3838

39-
Access the sample apps through the latest version folder from the repository's root with the following link. The projects are in the `BlazorWebAppOidc` folder for .NET 8 or later.
39+
Access the sample through the latest version folder in the Blazor samples repository with the following link. The sample is in the `BlazorWebAppOidc` folder for .NET 8 or later.
4040

4141
[View or download sample code](https://github.com/dotnet/blazor-samples) ([how to download](xref:blazor/fundamentals/index#sample-apps))
4242

@@ -251,9 +251,9 @@ The sample app only provides a user name and email for display purposes. It does
251251

252252
:::zone-end
253253

254-
:::zone pivot="without-bff-pattern-server"
254+
:::zone pivot="non-bff-pattern-server"
255255

256-
This version of the article covers implementing OIDC without adopting the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends) with an app that adopts global Interactive Server rendering (single project). The BFF pattern is useful for making authenticated requests to external services. Change the article version selector to **OIDC with BFF pattern** if the app's specification calls for adopting the BFF pattern with global Interactive Auto rendering.
256+
This version of the article covers implementing OIDC without adopting the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends) with an app that adopts global Interactive Server rendering (single project). The BFF pattern is useful for making authenticated requests to external services. Change the article version selector to **BFF pattern** if the app's specification calls for adopting the BFF pattern with global Interactive Auto rendering.
257257

258258
The following specification is covered:
259259

@@ -267,7 +267,7 @@ For an alternative experience using [Microsoft Authentication Library for .NET](
267267

268268
The sample app consists of a single server-side Blazor Web App project (`BlazorWebAppOidcServer`).
269269

270-
Access the sample app through the latest version folder from the repository's root with the following link. The project is in the `BlazorWebAppOidcServer` folder for .NET 8 or later.
270+
Access the sample through the latest version folder in the Blazor samples repository with the following link. The sample is in the `BlazorWebAppOidcServer` folder for .NET 8 or later.
271271

272272
[View or download sample code](https://github.com/dotnet/blazor-samples) ([how to download](xref:blazor/fundamentals/index#sample-apps))
273273

@@ -434,9 +434,9 @@ Inspect the sample app for the following features:
434434

435435
:::zone-end
436436

437-
:::zone pivot="with-bff-pattern"
437+
:::zone pivot="bff-pattern"
438438

439-
This version of the article covers implementing OIDC with the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends). Change the article version selector to **OIDC without BFF pattern** if the app's specification doesn't call for adopting the BFF pattern.
439+
This version of the article covers implementing OIDC with the [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends). Change the article version selector to **Non-BFF pattern** if the app's specification doesn't call for adopting the BFF pattern.
440440

441441
The following specification is covered:
442442

@@ -468,7 +468,7 @@ The sample app consists of five projects:
468468
* `BlazorWebAppOidc`: Server-side project of the Blazor Web App.
469469
* `BlazorWebAppOidc.Client`: Client-side project of the Blazor Web App.
470470

471-
Access the sample apps through the latest version folder from the repository's root with the following link. The projects are in the `BlazorWebAppOidcBff` folder for .NET 8 or later.
471+
Access the sample through the latest version folder in the Blazor samples repository with the following link. The sample is in the `BlazorWebAppOidcBff` folder for .NET 8 or later.
472472

473473
[View or download sample code](https://github.com/dotnet/blazor-samples) ([how to download](xref:blazor/fundamentals/index#sample-apps))
474474

@@ -549,7 +549,7 @@ The following <xref:Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConn
549549
```
550550

551551
> [!NOTE]
552-
> When using Microsoft Entra ID, the `Weather.Get` scope is configured in the Azure or Entra portal in **Expose an API**.
552+
> When using Microsoft Entra ID, the `Weather.Get` scope is configured in the Entra or Azure portal in **Expose an API**.
553553
554554
Example:
555555

@@ -731,7 +731,7 @@ Configure the project in the <xref:Microsoft.AspNetCore.Authentication.JwtBearer
731731
```
732732

733733
> [!NOTE]
734-
> When using Microsoft Entra ID, match the value to just the path of the **Application ID URI** configured when adding the `Weather.Get` scope under **Expose an API** in the Azure or Entra portal.
734+
> When using Microsoft Entra ID, match the value to just the path of the **Application ID URI** configured when adding the `Weather.Get` scope under **Expose an API** in the Entra or Azure portal.
735735
736736
Example:
737737

@@ -776,7 +776,7 @@ Configure the project in the <xref:Microsoft.AspNetCore.Authentication.JwtBearer
776776

777777
### Minimal API for weather data
778778

779-
Secure weather forecast data endpoint in the project's `Program` file:
779+
A secure weather forecast data endpoint in the project's `Program` file:
780780

781781
```csharp
782782
app.MapGet("/weather-forecast", () =>
@@ -813,7 +813,7 @@ Alternatively, use the following `LogInOrOut` component, which doesn't supply a
813813
<AntiforgeryToken />
814814
<button type="submit" class="nav-link">
815815
<span class="bi bi-arrow-bar-left-nav-menu" aria-hidden="true">
816-
</span> Logout @context.User.Identity?.Name
816+
</span> Logout
817817
</button>
818818
</form>
819819
</Authorized>

aspnetcore/zone-pivot-groups.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ groups:
8484
title: Specification
8585
prompt: Choose the app specification
8686
pivots:
87-
- id: without-bff-pattern
88-
title: OIDC without BFF pattern (Auto)
89-
- id: without-bff-pattern-server
90-
title: OIDC without BFF pattern (Server)
91-
- id: with-bff-pattern
92-
title: OIDC with BFF pattern (Auto)
87+
- id: non-bff-pattern
88+
title: Non-BFF pattern (Interactive Auto)
89+
- id: non-bff-pattern-server
90+
title: Non-BFF pattern (Interactive Server)
91+
- id: bff-pattern
92+
title: BFF pattern (Interactive Auto)
9393
- id: tooling
9494
title: Tooling
9595
prompt: Select your tooling
@@ -104,7 +104,7 @@ groups:
104104
title: Specification
105105
prompt: Choose the app specification
106106
pivots:
107-
- id: without-bff-pattern
108-
title: Entra without BFF pattern
109-
- id: with-bff-pattern
110-
title: Entra with BFF pattern
107+
- id: non-bff-pattern
108+
title: Non-BFF pattern
109+
- id: bff-pattern
110+
title: BFF pattern

0 commit comments

Comments
 (0)