You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/bff/architecture/multi-frontend.md
+35-12Lines changed: 35 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,36 +10,59 @@ sidebar:
10
10
variant: tip
11
11
---
12
12
13
-
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.
13
+
BFF V4.0 introduces the capability to support multiple BFF Frontends in a single host. This helps to simplify your
14
+
application landscape by consolidating multiple physical BFF Hosts into a single deployable unit.
14
15
15
16
A single BFF setup consists of:
16
17
1. A browser based application, typically built using technology like React, Angular or VueJS. This is typically deployed to a Content Delivery Network (CDN).
17
18
2. A BFF host, that will take care of the OpenID Connect login flows.
18
19
3. An API surface, exposed and protected by the BFF.
19
20
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.
21
+
With the BFF Multi-frontend support, you can logically host multiple of these BFF Setups in a single host. The concept
22
+
of a single frontend (with OpenID Connect configuration, an API surface and a browser based app) is now codified inside
23
+
the BFF. By using a flexible frontend selection mechanism (using Hosts or Paths to distinguish), it's possible to
24
+
create very flexible setups.
21
25
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).
26
+
The BFF dynamically configures the aspnet core authentication pipeline according to recommended practices. For example,
27
+
when doing Host based routing, it will configure the cookies using the most secure settings and with the prefix
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.
30
+
Frontends can be added or removed dynamically from the system, without having to restart the system. You can do this
31
+
via configuration (for example by modifying a configuration file) or programmatically.
25
32
26
33
:::note
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.
34
+
The Duende BFF V4 library doesn't ship with an abstraction to store or read frontends from a database. It's possible
35
+
to implement this by creating your own store (based on your requirements), then modify the `FrontendCollection` at
36
+
run-time.
28
37
:::
29
38
30
39
## A Typical Example
31
40
32
-
Consider an enterprise that hosts multiple browser based applications. Each of these applications is developed by a separate team and as such, has its own deployment schedule.
41
+
Consider an enterprise that hosts multiple browser based applications. Each of these applications is developed by a
42
+
separate team and as such, has its own deployment schedule.
33
43
34
-
There are some internal-facing applications that are exclusively used by internal employees. These internal employees are all present in Microsoft Entra ID, so these internal-facing applications should directly authenticate against Microsoft Entra ID. These applications also use several internal APIs, that due to the sensitivity, should not be accessible by external users. However, they also use some of the more common APIs. These apps are only accessible via an internal DNS name, such as `https://app1.internal.example.com`.
44
+
There are some internal-facing applications that are exclusively used by internal employees. These internal employees
45
+
are all present in Microsoft Entra ID, so these internal-facing applications should directly authenticate against
46
+
Microsoft Entra ID. These applications also use several internal APIs, that due to the sensitivity, should not be
47
+
accessible by external users. However, they also use some of the more common APIs. These apps are only accessible via
48
+
an internal DNS name, such as `https://app1.internal.example.com`.
35
49
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, via providers like Google, Twitter, or others. 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`
50
+
There are also several public facing applications, that are used directly by customers. These users should be able to
51
+
log in using their own identity, via providers like Google, Twitter, or others. This authentication process is handled
52
+
by Duende IdentityServer. There is constant development ongoing on these applications and it's not uncommon for new
53
+
applications to be introduced. There should be single sign-on across all these public facing applications. They are
54
+
all available on the same domain name, but use path based routing to distinguish themselves, such as
55
+
`https://app.example.com/app1`
37
56
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.md) feature of Duende IdentityServer.
57
+
There is also a partner portal. This partner portal can only be accessed by employees of the partners. Each partner
58
+
should be able to bring their own identity provider. This is implemented using the [Dynamic Providers](/identityserver/ui/login/dynamicproviders.md) feature of
59
+
Duende IdentityServer.
39
60
40
-
This setup, with multiple frontends, each having different authentication requirements and different API surfaces, is now supported by the BFF.
61
+
This setup, with multiple frontends, each having different authentication requirements and different API surfaces,
62
+
is now supported by the BFF.
41
63
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.
64
+
Each frontend can either rely on the global configuration or override (parts of) this configuration, such as the
65
+
identity provider or the Client ID and Client Secret to use.
43
66
44
67
It's also possible to dynamically add or remove frontends, without restarting the BFF host.
45
68
@@ -51,7 +74,7 @@ To achieve this, the BFF automatically configures the ASP.NET Core pipeline:
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.
77
+
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 and host based routing, so the most specific will be selected.
55
78
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
79
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
80
4. Your own applications logic is executed in this part of the pipeline. For example, calling `.UseAuthentication(), .UseRequestLogging()`, etc.
Duende.BFF (Backend for Frontend) supports multiple frontends in a single BFF host. This is useful for scenarios where you want to serve several SPAs or frontend apps from the same backend, each with their own authentication and API proxying configuration.
14
+
Duende.BFF (Backend for Frontend) supports multiple frontends in a single BFF host. This is useful for scenarios where
15
+
you want to serve several SPAs or frontend apps from the same backend, each with their own authentication and API
16
+
proxying configuration.
15
17
16
18
:::note
17
-
Multi-frontend support is available in Duende.BFF v4 and later. The v3-style of wiring up BFF is not supported for this scenario.
19
+
Multi-frontend support is available in Duende.BFF v4 and later. The v3-style of wiring up BFF is not supported for
20
+
this scenario.
18
21
:::
19
22
20
23
## Prerequisites
@@ -39,7 +42,8 @@ dotnet add package Duende.BFF
39
42
40
43
### 3. OpenID Connect Configuration
41
44
42
-
Configure OpenID Connect authentication for your BFF host. This is similar to the single frontend setup, but applies to all frontends unless overridden per frontend.
45
+
Configure OpenID Connect authentication for your BFF host. This is similar to the single frontend setup, but applies
0 commit comments