Skip to content

Commit ed09f00

Browse files
committed
BFF v4 - Document RequireAccessToken -> WithAccessToken
1 parent dda4b82 commit ed09f00

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Implementations of the *IAccessTokenRetriever* can be added to endpoints when th
113113
app.MapRemoteBffApiEndpoint(
114114
"/API/impersonation",
115115
"https://API.example.com/endpoint/requiring/impersonation"
116-
).RequireAccessToken(TokenType.User)
116+
).WithAccessToken(RequiredTokenType.User)
117117
.WithAccessTokenRetriever<ImpersonationAccessTokenRetriever>();
118118
```
119119

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ The `MapRemoteBffApiEndpoint` extension method maps a path and all sub-paths bel
4444
```csharp
4545
// Program.cs
4646
app.MapRemoteBffApiEndpoint("/API/users", "https://remoteHost/users")
47-
.RequireAccessToken(TokenType.User);
47+
.WithAccessToken(RequiredTokenType.User);
4848
```
4949

5050
:::note
5151
This example opens up the complete */users* API namespace to the frontend, and thus, to the outside world. While it is convenient to register API paths this way, consider if you need to be more specific hen designing the forwarding paths to prevent accidentally exposing unintended endpoints.
5252
:::
5353

54-
The `RequireAccessToken` method can be added to [specify token requirements](#access-token-requirements) for the remote API. The BFF will automatically forward the correct access token to the remote API, which will be scoped to the client application, the user, or either.
54+
The `WithAccessToken` method can be added to [specify token requirements](#access-token-requirements) for the remote API. The BFF will automatically forward the correct access token to the remote API, which will be scoped to the client application, the user, or either.
5555

5656
## Securing Remote APIs
5757

@@ -81,11 +81,19 @@ The value of the header is not important, but its presence, combined with the co
8181

8282
#### Require authorization
8383

84-
The `MapRemoteBffApiEndpoint` method returns the appropriate type to integrate with the ASP.NET Core authorization system. You can attach authorization policies to remote endpoints using `RequireAuthorization` extension method, just as you would for a standard ASP.NET core endpoint created with `MapGet`. The authorization middleware will then enforce that policy before forwarding requests on that route to the remote endpoint.
84+
The `MapRemoteBffApiEndpoint` method returns the appropriate type to integrate with the ASP.NET Core authorization system. You can attach authorization policies to remote endpoints using the `WithAccessToken` extension method, just as you would for a standard ASP.NET core endpoint created with `MapGet`. The authorization middleware will then enforce that policy before forwarding requests on that route to the remote endpoint.
85+
86+
:::note
87+
In Duende.BFF version 3, use the `MapRemoteBffApiEndpoint` method with the `RequireAuthorization` extension method to attach authorization policies.
88+
:::
8589

8690
#### Access token requirements
8791

88-
Remote APIs sometimes allow anonymous access, but usually require an access token, and the type of access token (user or client) will vary as well. You can specify access token requirements via the `RequireAccessToken` extension method. Its `TokenType` parameter has three options:
92+
Remote APIs sometimes allow anonymous access, but usually require an access token, and the type of access token (user or client) will vary as well. You can specify access token requirements via the `WithAccessToken` extension method. Its `RequiredTokenType` parameter has three options:
93+
94+
* `None`
95+
96+
No token is required.
8997

9098
* `User`
9199

@@ -99,7 +107,9 @@ Remote APIs sometimes allow anonymous access, but usually require an access toke
99107

100108
Either a valid user access token or a valid client access token (as fallback) is required and will be forwarded to the remote API.
101109

102-
You can also use the `WithOptionalUserAccessToken` extension method to specify that the API should be called with a user access token if one is available and anonymously if not.
110+
* `UserOrNone`
111+
112+
A valid user access token will be forwarded to the remote API when logged in. No access token will be sent when not logged in, and no OIDC flow is challenged to get an access token.
103113

104114
:::note
105115
These settings only specify the logic that is applied before the API call gets proxied. The remote APIs you are calling should always specify their own authorization and token requirements.

src/content/docs/bff/upgrading/bff-v3-to-v4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ app.MapRemoteBffApiEndpoint("/api/optional-user-token", "https://localhost:5010"
4040
+ .WithAccessToken(RequiredTokenType.UserOrNone);
4141
```
4242

43-
* The enum `TokenType` has been renamed to `RequiredTokenType`.
43+
* The enum `TokenType` has been renamed to `RequiredTokenType`, and moved from the `Duende.Bff` to `Duende.Bff.AccessTokenManagement` namespace.
4444
* The methods to configure the token type have all been replaced with a new method `WithAccessToken()`
4545
* Requesting an optional access token should no longer be done by calling `WithOptionalUserAccessToken()`. Use `WithAccessToken(RequiredTokenType.UserOrNone)` instead.
4646

src/content/docs/identityserver/quickstarts/javascript-clients/js-with-backend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ API in the ASP.NET Core routing system. Add the code below to the endpoint confi
425425
.AsBffApiEndpoint();
426426

427427
app.MapRemoteBffApiEndpoint("/remote", "https://localhost:6001")
428-
.RequireAccessToken(Duende.Bff.TokenType.User);
428+
.WithAccessToken(Duende.Bff.AccessTokenManagement.RequiredTokenType.User);
429429
```
430430
The call to the `AsBffApiEndpoint()` fluent helper method adds BFF support to
431431
the local APIs. This includes anti-forgery protection and suppressing

0 commit comments

Comments
 (0)