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
The most common way to use the access token management for [machine-to-machine communication](/accesstokenmanagement/workers) - however, you may want to customize certain aspects of it. Here's what you can do.
12
+
The most common way to use the access token management for [machine-to-machine communication](/accesstokenmanagement/workers).
13
+
However, you may want to customize certain aspects of it.
Copy file name to clipboardExpand all lines: src/content/docs/accesstokenmanagement/advanced/dpop.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,14 @@ redirect_from:
8
8
- /foss/accesstokenmanagement/advanced/dpop/
9
9
---
10
10
11
-
[DPoP](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop) specifies how to bind an asymmetric key stored within a JSON Web Key (JWK) to an access token. This will make the access token bound to the key such that if the access token were to leak, it cannot be used without also having access to the private key of the corresponding JWK.
11
+
[DPoP](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop) specifies how to bind an asymmetric key stored within a JSON Web Key (JWK) to an access token.
12
+
This will make the access token bound to the key such that if the access token were to leak, it cannot be used without also having access to the private key of the corresponding JWK.
12
13
13
-
The "Duende.AccessTokenManagement" library supports DPoP.
14
+
The Duende.AccessTokenManagement library supports DPoP.
14
15
15
16
## DPoP Key
16
17
17
-
The main piece that your hosting application needs to concern itself with is how to obtain (and manage) the DPoP key. This key (and signing algorithm) will be either an "RS", "PS", or "ES" style key, and needs to be in the form of a JSON Web Key (or JWK). Consult the specification for more details.
18
+
The main piece that your hosting application needs to concern itself with is how to get (and manage) the DPoP key. This key (and signing algorithm) will be either an "RS", "PS", or "ES" style key, and needs to be in the form of a JSON Web Key (or JWK). Consult the specification for more details.
18
19
19
20
The creation and management of this DPoP key is up to the policy of the client. For example is can be dynamically created when the client starts up, and can be periodically rotated. The main constraint is that it must be stored for as long as the client uses any access tokens (and possibly refresh tokens) that they are bound to, which this library will manage for you.
20
21
@@ -73,11 +74,11 @@ When using DPoP and `AddOpenIdConnectAccessTokenManagement`, this library will a
73
74
74
75
## Proof Tokens At The API
75
76
76
-
Once the library has obtained a DPoP bound access token for the client, then if your application is using any of the `HttpClient` client factory helpers (e.g. `AddClientCredentialsHttpClient` or `AddUserAccessTokenHttpClient`) then those outbound HTTP requests will automatically include a DPoP proof token for the associated DPoP access token.
77
+
Once the library has gotten a DPoP bound access token for the client, then if your application is using any of the `HttpClient` client factory helpers (e.g. `AddClientCredentialsHttpClient` or `AddUserAccessTokenHttpClient`) then those outbound HTTP requests will automatically include a DPoP proof token for the associated DPoP access token.
77
78
78
79
## Considerations
79
80
80
81
A point to keep in mind when using DPoP and `AddOpenIdConnectAccessTokenManagement` is that the DPoP proof key is created per user session.
81
82
This proof key must be store somewhere, and the `AuthenticationProperties` used by both the OIDC and cookie handlers is what is used to store this key.
82
83
This implies that the OIDC `state` parameter will increase in size, as well the resultant cookie that represents the user's session.
83
-
The storage of each of these can be customized with the properties on the options `StateDataFormat` and `SessionStore` respectively.
84
+
The storage for each of these can be customized with the properties on the options `StateDataFormat` and `SessionStore` respectively.
Copy file name to clipboardExpand all lines: src/content/docs/accesstokenmanagement/blazor-server.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ This means:
19
19
20
20
Fortunately, `Duende.AccessTokenManagement` provides a straightforward solution to these problems. Also see the [*BlazorServer* sample](https://github.com/DuendeSoftware/foss/tree/main/access-token-management/samples/BlazorServer) for source code of a full example.
21
21
22
-
## Token storage
22
+
## Token Storage
23
23
24
24
Since the tokens cannot be managed in the authentication session, you need to store them somewhere else. The options include an in-memory data structure, a distributed cache like redis, or a database. Duende.AccessTokenManagement describes this store for tokens with the *IUserTokenStore* interface. In non-blazor scenarios, the default implementation that stores the tokens in the session is used. In your Blazor server application, you'll need to decide where you want to store the tokens and implement the store interface.
The `Duende.AccessTokenManagement` library provides automatic access token management features for .NET worker and ASP.NET Core web applications:
14
14
15
-
-automatic acquisition and lifetime management of client credentials based access tokens for machine-to-machine communication (using the `Duende.AccessTokenManagement` package)
16
-
-automatic access token lifetime management using a refresh token for API calls on behalf of the currently logged-in user (using the `Duende.AccessTokenManagement.OpenIdConnect` package)
17
-
-revocation of access tokens
15
+
-Automatic acquisition and lifetime management of client credentials based access tokens for machine-to-machine communication (using the `Duende.AccessTokenManagement` package)
16
+
-Automatic access token lifetime management using a refresh token for API calls on behalf of the currently logged-in user (using the `Duende.AccessTokenManagement.OpenIdConnect` package)
17
+
-Revocation of access tokens
18
18
19
-
:::note
20
-
Duende.AccessTokenManagement version 4 (currently in preview 2) brings significant improvements, but also several breaking
21
-
changes. Please see the [migration guide](/accesstokenmanagement/upgrading/atm-v3-to-v4/) and [release notes](https://github.com/DuendeSoftware/foss/releases/tag/atm-4.0.0-Preview.2).
19
+
:::note[Duende.AccessTokenManagement version 4 preview]
20
+
Duende.AccessTokenManagement version 4 (preview) brings significant improvements, but also several breaking
21
+
changes. Please see the [migration guide](/accesstokenmanagement/upgrading/atm-v3-to-v4/) and [release notes](https://github.com/DuendeSoftware/foss/releases/tag/atm-4.0.0-Preview.2).
22
22
:::
23
-
24
23
25
-
## Machine-to-machine token management
24
+
## Machine-To-Machine Token Management
26
25
27
26
To get started, install the NuGet Package:
28
27
@@ -45,7 +44,7 @@ See [Service Workers and Background Tasks](/accesstokenmanagement/workers.md) fo
45
44
/>
46
45
</CardGrid>
47
46
48
-
## User token management
47
+
## User Token Management
49
48
50
49
To get started, install the NuGet Package:
51
50
@@ -68,6 +67,7 @@ See [Web Applications](/accesstokenmanagement/web-apps.md) for more information
68
67
/>
69
68
</CardGrid>
70
69
71
-
## License and Feedback
70
+
## License And Feedback
72
71
73
-
**Duende.AccessTokenManagement** is released as open source under the Apache 2.0 license. Bug reports, feature requests and contributions are welcome. If you have an idea for a new feature or significant code change you'd like to propose, please start with a GitHub issue so that we can discuss it. Thanks in advance!
72
+
**Duende.AccessTokenManagement** is released as open source under the Apache 2.0 license.
73
+
Bug reports, feature requests and contributions are welcome via the [Duende community discussions](https://duende.link/community).
Copy file name to clipboardExpand all lines: src/content/docs/accesstokenmanagement/upgrading/atm-v3-to-v4.mdx
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,16 @@
1
1
---
2
2
title: "Duende AccessTokenManagement v3.x to v4.0"
3
-
description: Guide for upgrading Duende BFF Security Framework from version 3.x to version 4.0, including migration steps for custom implementations and breaking changes.
3
+
description: Guide for upgrading Duende.AccessTokenManagement from version 3.x to version 4.0, including migration steps for custom implementations and breaking changes.
4
4
sidebar:
5
5
label: v3.x → v4.0
6
6
order: 100
7
7
---
8
8
9
9
## Changes
10
-
### Moving Towards HybridCache Implementation and Away from Distributed Cache
11
10
12
-
Microsoft has recently released HybridCache. While this is only released as a .NET 9 DLL, these assemblies work fine in .NET 8. So, while we still support .NET 8 with ATM 4.0, we are moving towards using HybridCache.
11
+
### Moving Towards HybridCache Implementation And Away from Distributed Cache
12
+
13
+
Microsoft has recently released [HybridCache](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid). While this is only released as a .NET 9 assembly, these assemblies work fine in .NET 8. So, while we still support .NET 8 with ATM 4.0, we are moving towards using HybridCache.
13
14
14
15
HybridCache brings significant improvements for us. Because of the two-layered cache, we've found it significantly improves performance.
15
16
If you currently use a distributed cache, this should still work seamlessly.
@@ -31,9 +32,11 @@ The library has undergone extensive internal changes—so much so that it can be
31
32
32
33
All internal implementation details are now marked as internal, reducing accidental coupling and clarifying the intended extension points. In V3, all classes were public and most public methods were marked as virtual. This meant you could override any class by inheriting from it and overriding a single method.
33
34
34
-
While this was very convenient for our consumers, it made it very difficult for us to introduce changes to the library without making breaking changes.
35
+
While this was very convenient for our consumers, it made it challenging to introduce changes to the library without making breaking changes.
35
36
36
-
We still want to ensure our users' extensibility needs are met, but via more controlled mechanisms. If you find that you have an extensibility need that is not covered by the new model, please raise a discussion in our discussion board. If this is a scenario we want to support, we'll do our best to accommodate it.
37
+
We still want to ensure our users' extensibility needs are met, but via more controlled mechanisms.
38
+
If you find that you have an extensibility need not covered by the new model, please raise a discussion [in our discussion board](https://duende.link/community).
39
+
If this is a scenario we want to support, we'll do our best to accommodate it.
37
40
38
41
### Explicit Extension Model
39
42
@@ -55,15 +58,15 @@ For example:
55
58
56
59
```csharp
57
60
varscheme=Scheme.Parse("oidc");
58
-
59
61
```
60
62
61
63
### Renamed classes
62
-
Several classes have been renamed, either to make their usage clearer or to drop the 'service' suffix, which only adds noise:
Copy file name to clipboardExpand all lines: src/content/docs/accesstokenmanagement/web-apps.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,32 +16,32 @@ While many of the details can be customized, by default the following is assumed
16
16
17
17
* ASP.NET Core web application
18
18
* cookie authentication handler for session management
19
-
* OpenID Connect authentication handler for authentication and access token requests against an OpenID Connect compliant
20
-
token service
19
+
* OpenID Connect authentication handler for authentication and access token requests against an OpenID Connect compliant token service
21
20
* the token service returns a refresh token
22
21
23
-
Using this library, you can either request `user access tokens` or `client credentials tokens`. User access tokens typically contain information about the currently logged in user, such as the `sub` claim. They are used to access services under the credentials of the currently logged in user. `Client credentials tokens` do not contain information about the currently logged in user and are typically used to do machine-to-machine calls.
22
+
Using this library, you can either request `user access tokens` or `client credentials tokens`. User access tokens typically contain information about the currently logged in user, such as the `sub` claim.
23
+
They are used to access services under the credentials of the currently logged in user. `Client credentials tokens` do not contain information about the currently logged in user and are typically used to do machine-to-machine calls.
24
24
25
-
## Usage
26
-
First, you'll need to add `Duende.AccessTokenManagement.OpenIdConnect` to your solution.
25
+
To get started, you'll need to add `Duende.AccessTokenManagement.OpenIdConnect` to your solution.
27
26
28
27
Then, there are two fundamental ways to interact with token management:
29
28
1.**Automatic** <Badgetext="recommended"/>: You request a http client from the IHTTPClientFactory. This http client automatically requests, optionally renews and attaches the access tokens on each request.
30
29
2.**Manually** <Badgetext="advanced"/>: You request an access token, which you can then use to (for example) authenticate with services. You are responsible for attaching the access token to requests.
31
30
32
-
### Adding AccessTokenManagement to your project
31
+
Let's look at these steps in more detail.
33
32
33
+
## Adding AccessTokenManagement To Your Project
34
34
35
35
To use this library, start by adding the library to your .NET projects.
Last but not least, if you registered clients with the factory, you can use them. They will try to make sure that a
151
-
current access token is always sent along. If that is not possible, ultimately a 401 will be returned to the calling
151
+
current access token is always sent along. If that is not possible, ultimately a `401` HTTP status code will be returned to the calling
152
152
code.
153
153
154
154
```csharp
@@ -173,9 +173,9 @@ public async Task<IActionResult> CallApi([FromServices] InvoiceClient client)
173
173
}
174
174
```
175
175
176
-
###Manually request access tokens
176
+
## Manually Request Access Tokens
177
177
178
-
If you want to use access tokens in a different way or have more advanced needs which the automatic option doesn't cover, then you can also manually request user access tokens.
178
+
If you want to use access tokens differently or have more advanced needs which the automatic option doesn't cover, then you can also manually request user access tokens.
0 commit comments