Skip to content

Commit 1e5cedf

Browse files
committed
Apply suggestions from code review
1 parent a69d4e3 commit 1e5cedf

File tree

7 files changed

+46
-37
lines changed

7 files changed

+46
-37
lines changed

src/content/docs/bff/architecture/multi-frontend.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,64 @@
22
title: "Multi-frontend support"
33
description: Overview on what BFF multi-frontend support is, how it works and why you would use it.
44
date: 2024-06-11T08:22:12+02:00
5+
sidebar:
6+
label: "Multiple Frontends"
7+
order: 5
8+
badge:
9+
text: v4
10+
variant: tip
511
---
612

713
BFF V4.0 introduces the capability to support multiple BFF Frontends in a single host. This helps to simplify your application landscape by consolidating multiple physical BFF Hosts into a single deployable unit.
814

915
A single BFF setup consists of:
10-
1. A browser based application, typically built using technology like React, Angular or VueJS. This is typically deployed to a CDN.
16+
1. A browser based application, typically built using technology like React, Angular or VueJS. This is typically deployed to a Content Delivery Network (CDN).
1117
2. A BFF host, that will take care of the OpenID Connect login flows.
12-
3. An api surface, exposed and protected by the BFF.
18+
3. An API surface, exposed and protected by the BFF.
1319

14-
With the BFF Multi-frontend support, you can logically host multiple of these BFF Setups in a single host. The concept of a single frontend (with OpenID Connect configuration, an api surface and a browser based app) is now codified inside the BFF. By using a flexibile frontend selection mechanism (using Origins or Paths to distinguish), it's possible to create very flexible setups.
20+
With the BFF Multi-frontend support, you can logically host multiple of these BFF Setups in a single host. The concept of a single frontend (with OpenID Connect configuration, an API surface and a browser based app) is now codified inside the BFF. By using a flexible frontend selection mechanism (using Origins or Paths to distinguish), it's possible to create very flexible setups.
1521

16-
The BFF dynamically configures the aspnet core authentication pipeline according to recommended practices. For example, when doing Origin based routing, it will configure the cookies using the most secure settings and with the prefix [__Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie).
22+
The BFF dynamically configures the aspnet core authentication pipeline according to recommended practices. For example, when doing Origin based routing, it will configure the cookies using the most secure settings and with the prefix [`__Host`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie).
1723

1824
Frontends can be added or removed dynamically from the system, without having to restart the system. You can do this via configuration (for example by modifying a configuration file) or programmatically.
1925

2026
:::note
21-
The duende BFF V4 library doesn't ship with an abstraction to store or read frontends from a database. It's possible to implement this by creating your own store (based on your requirements), then modify the **FrontendCollection** at run-time.
27+
The Duende BFF V4 library doesn't ship with an abstraction to store or read frontends from a database. It's possible to implement this by creating your own store (based on your requirements), then modify the `FrontendCollection` at run-time.
2228
:::
2329

2430
## A typical example
2531

26-
Consider an enterprise who hosts multiple browser based applications. Each of these applications is developed by a separate team and as such, has it's own deployment schedule.
32+
Consider an enterprise that hosts multiple browser based applications. Each of these applications is developed by a separate team and as such, has it's own deployment schedule.
2733

28-
There are some 'internally facing' applications that are exclusively used by internal employees. These internal employees are all present in Microsoft Entra ID, so these internally facing applications should directly authenticate against Microsoft Entra ID. These applications also use several internal api's, that due to the sensitivity, should not be accessible by external users. However, they also use some of the more common api's. These apps are only accessible via an internal DNS name, such as https://app1.internal.company.com.
34+
There are some 'internally facing' applications that are exclusively used by internal employees. These internal employees are all present in Microsoft Entra ID, so these internally facing applications should directly authenticate against Microsoft Entra ID. These applications also use several internal api's, that due to the sensitivity, should not be accessible by external users. However, they also use some of the more common api's. These apps are only accessible via an internal DNS name, such as `https://app1.internal.example.com`.
2935

30-
There are also several public facing applications, that are used directly by customers. These users should be able to log in using their own identity, such as a GMail, Twitter or other provider. This authentication process is handled by Duende Identity Server. There is constant development ongoing on these applications and it's not uncommon for new applications to be introduced. There should be single signon across all these public facing applictions. They are all available on the same domain name, but use path based routing to distinguish themselves, such as https://app.company.com/app1
36+
There are also several public facing applications, that are used directly by customers. These users should be able to log in using their own identity, such as a GMail, Twitter or other provider. This authentication process is handled by Duende IdentityServer. There is constant development ongoing on these applications and it's not uncommon for new applications to be introduced. There should be single sign-on across all these public facing applications. They are all available on the same domain name, but use path based routing to distinguish themselves, such as `https://app.example.com/app1`
3137

32-
Then there is a partner portal. This partner portal can only be accessed by employees of the partners. Each partner should be able to bring their own identity provider. This is implemented using the Dynamic Providers feature of Duende Identity Server.
38+
There is also a partner portal. This partner portal can only be accessed by employees of the partners. Each partner should be able to bring their own identity provider. This is implemented using the [Dynamic Providers](/identityserver/ui/login/dynamicproviders/) feature of Duende IdentityServer.
3339

34-
This setup, where there are multiple frontends, which different authentication requirements and different api surfaces, is now supported by the BFF.
40+
This setup, with multiple frontends, each having different authentication requirements and different API surfaces, is now supported by the BFF.
3541

36-
Each frontend can either rely on the 'global' configuration or override (parts of) this configuration, such as the identity provider or the Client ID and Client Secret to use.
42+
Each frontend can either rely on the global configuration or override (parts of) this configuration, such as the identity provider or the Client ID and Client Secret to use.
3743

3844
It's also possible to dynamically add or remove frontends, without restarting the BFF host.
3945

4046
## Internals
4147

42-
BFF V4 still allows you to manually configure the asp.net authentication options, by calling .AddAuthentication().AddOpenIdConnect().AddCookies(). However, if you wish to use the multi-frontend features, then this setup needs to become dynamic.
48+
BFF V4 still allows you to manually configure the ASP.NET Core authentication options, by calling `.AddAuthentication().AddOpenIdConnect().AddCookies()`. However, if you wish to use the multi-frontend features, then this setup needs to become dynamic.
4349

44-
To achieve this, the BFF automatically configures the AspNet pipeline:
50+
To achieve this, the BFF automatically configures the ASP.NET Core pipeline:
4551

4652
![BFF Multi-Frontend Pipeline](../images/bff_multi_frontend_pipeline.svg)
4753

48-
1. FrontendSelectionMiddleware. This middleware performs the frontend selection by seeing which frontend's selection criteria best matches the incoming request route. It's possible to mix both path based routing origin based routing, so the most specific will be selected.
49-
2. PathMappingMiddlweare. If you use path mapping, in the selected frontend, then it will automatically *map()* the frontend's path so none of the subsequent middlewares know (or need to care) about this fact.
50-
3. OpenIdCallbackMiddlware. To dynamically perform the openid connect authentication without explicitly adding each frontend as a scheme, we inject a middleware that will handle the openid connect callbacks. This only kicks in for dynamic frontends.
51-
4. Your own applications logic is executed in this part of the pipeline. For example, calling .UseAuthentication(), .UseRequestLogging(), etc.
54+
1. `FrontendSelectionMiddleware` - This middleware performs the frontend selection by seeing which frontend's selection criteria best matches the incoming request route. It's possible to mix both path based routing origin based routing, so the most specific will be selected.
55+
2. `PathMappingMiddleware` - If you use path mapping, in the selected frontend, then it will automatically map the frontend's path so none of the subsequent middlewares know (or need to care) about this fact.
56+
3. `OpenIdCallbackMiddleware` - To dynamically perform the OpenID Connect authentication without explicitly adding each frontend as a scheme, we inject a middleware that will handle the OpenID Connect callbacks. This only kicks in for dynamic frontends.
57+
4. Your own applications logic is executed in this part of the pipeline. For example, calling `.UseAuthentication(), .UseRequestLogging()`, etc.
5258

5359
After your application's logic is executed, there are two middlewares registered as fallback routes:
5460

55-
5. MapRemoteRoutesMiddlware. This will handle any configured remote routes. Note, it will not handle plain yarp calls, only routes that are specifically added to a frontend.
61+
5. `MapRemoteRoutesMiddleware` - This will handle any configured remote routes. Note, it will not handle plain YARP calls, only routes that are specifically added to a frontend.
5662

57-
6. ProxyIndexMiddleware. If configured, this proxy the IndexHTML to start the browser based app.
63+
6. `ProxyIndexMiddleware` - If configured, this proxy the `index.html` to start the browser based app.
5864

5965

src/content/docs/bff/extensibility/tokens.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ Implementations of the *IAccessTokenRetriever* can be added to endpoints when th
111111

112112
```cs
113113
app.MapRemoteBffApiEndpoint(
114-
"/API/impersonation",
115-
"https://API.example.com/endpoint/requiring/impersonation"
114+
"/api/impersonation",
115+
"https://api.example.com/endpoint/requiring/impersonation"
116116
).WithAccessToken(RequiredTokenType.User)
117117
.WithAccessTokenRetriever<ImpersonationAccessTokenRetriever>();
118118
```

src/content/docs/bff/fundamentals/apis/remote.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The `MapRemoteBffApiEndpoint` extension method maps a path and all sub-paths bel
4343

4444
```csharp
4545
// Program.cs
46-
app.MapRemoteBffApiEndpoint("/API/users", "https://remoteHost/users")
46+
app.MapRemoteBffApiEndpoint("/api/users", "https://remoteHost/users")
4747
.WithAccessToken(RequiredTokenType.User);
4848
```
4949

src/content/docs/bff/getting-started/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66
label: Overview
77
---
88

9-
Currently, the most recent version is 4 (preview 1). If you're upgrading from a previous version, please checkout our [upgrade guides](/bff/upgrading).
9+
Currently, the most recent version is 4 (preview 1). If you're upgrading from a previous version, please check our [upgrade guides](/bff/upgrading).
1010

1111
If you're starting a new BFF project, consider the following startup guides:
1212

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
2-
title: Getting Started - Multiple frontends
3-
description: A guide on how to create a BFF application with a single frontend.
2+
title: Getting Started - Multiple Frontends
3+
description: A guide on how to create a BFF application with multiple frontends.
44
sidebar:
55
order: 20
6-
label: Multiple frontends
6+
label: "Multiple Frontends"
7+
badge:
8+
text: v4
9+
variant: tip
710
---

src/content/docs/bff/getting-started/single-frontend.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ title: Getting Started - Single Frontend
33
description: A guide on how to create a BFF application with a single frontend.
44
sidebar:
55
order: 10
6-
label: Single frontend
6+
label: "Single Frontend"
77
---
88
import { Code } from "astro/components";
99
import { Tabs, TabItem } from "@astrojs/starlight/components";
1010

1111
Duende.BFF (Backend for Frontend) is a library that helps you build secure, modern web applications by acting as a security gateway between your frontend and backend APIs. This guide will walk you through setting up a simple BFF application with a single frontend.
1212

1313
:::note
14-
Duende.BFF V4 introduces this new way of configuring the BFF, which automatically configures the BFF using recommended practices. If you're upgrading from V3, please refer to the [upgrade guide](/bff/upgrading/bff-v3-to-v4)
14+
Duende.BFF V4 introduced a new way of configuring the BFF, which automatically configures the BFF using recommended practices. If you're upgrading from V3, please refer to the [upgrade guide](/bff/upgrading/bff-v3-to-v4).
1515
:::
1616

1717
## Prerequisites
1818

1919
- .NET 8.0 or later
2020
- A frontend application (e.g., React, Angular, Vue, or plain JavaScript)
2121

22-
## Setting up a BFF project
22+
## Setting Up A BFF project
2323

24-
### 1. Create a New ASP.NET Core Project
24+
### 1. Create A New ASP.NET Core Project
2525

2626
Create a new ASP.NET Core Web Application:
2727

@@ -30,15 +30,15 @@ dotnet new web -n MyBffApp
3030
cd MyBffApp
3131
```
3232

33-
### 2. Add the Duende.BFF NuGet Package
33+
### 2. Add The Duende.BFF NuGet Package
3434

3535
Install the Duende.BFF package:
3636

3737
```sh
3838
dotnet add package Duende.BFF
3939
```
4040

41-
### 3. Configure BFF in `Program.cs`
41+
### 3. Configure BFF In `Program.cs`
4242

4343
Add the following to your `Program.cs`:
4444

@@ -136,15 +136,15 @@ Add the following to your `Program.cs`:
136136

137137
Make sure to replace the Authority, ClientID and ClientSecret with values from your identity provider. Also consider if the scopes are correct.
138138

139-
## Adding local api's
139+
## Adding Local APIs
140140

141-
If your browser based application uses local api's, you can add those directly to your BFF app. The BFF supports both controllers and minimal api's to create local api's.
141+
If your browser-based application uses local APIs, you can add those directly to your BFF app. The BFF supports both controllers and minimal APIs to create local API endpoints.
142142

143143

144144

145145

146146

147-
## Adding remote api's
147+
## Adding Remote APIs
148148

149149
## Adding Server Side Sessions
150150

src/content/docs/bff/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ The source code for the BFF framework can be found on GitHub. Builds are distrib
4141
/>
4242
</CardGrid>
4343

44-
## Getting started
44+
## Getting Started
4545

46-
Currently, the most recent version is 4 (preview 1). If you're upgrading from a previous version, please checkout our [upgrade guides](/bff/upgrading).
46+
Currently, the most recent version is 4 (preview 1). If you're upgrading from a previous version, please check our [upgrade guides](/bff/upgrading).
4747

4848
If you're starting a new BFF project, consider the following startup guides:
4949
* [Single frontend BFF](/bff/getting-started/single-frontend)

0 commit comments

Comments
 (0)