Repository navigation
docs(spaces): document resolution cache options and data protection behavior #1298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
42c7f32
docs(spaces): document resolution cache options and data protection b…
maartenba b534a98
docs(spaces): clarify which scheme providers are not partitioned
maartenba 2cf3e95
docs(spaces): other instances see space changes within LocalCacheExpi…
maartenba 2756812
docs(spaces): warn against disabling PartitionDataProtection after de…
maartenba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
astro/src/content/docs/identityserver/spaces/data-protection.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| title: "Data Protection In Spaces" | ||
| description: "How Spaces partitions ASP.NET Core Data Protection by space, including the Default space fallback, failures outside a resolved space, and which providers are partitioned." | ||
| date: 2026-11-02 | ||
| sidebar: | ||
| label: "Data Protection" | ||
| order: 20 | ||
| --- | ||
|
|
||
| Spaces partitions [ASP.NET Core Data Protection](/general/data-protection.md) by space when | ||
| `SpacesOptions.PartitionDataProtection` is `true`, which is the default. A protector created from the app's | ||
| `IDataProtectionProvider` binds to the space that is resolved when it protects or unprotects a value. A value protected | ||
| in one space can't be unprotected in another. Use `GetUnpartitioned()` on the provider for data that must be readable | ||
| from every space. | ||
|
|
||
| This page describes how partitioning behaves at runtime and where its limits are. To turn partitioning on or off, see | ||
| [Getting Started With Spaces](/identityserver/spaces/getting-started.md#before-deployment). | ||
|
|
||
| ## Protecting Data Outside A Resolved Space | ||
|
|
||
| If `IDataProtector.Protect` or `IDataProtector.Unprotect` runs with no resolved space, Spaces throws an | ||
| `InvalidOperationException` instead of falling back to a shared key. The message starts with "Data protection was used | ||
| with no resolved space while SpacesOptions.PartitionDataProtection is enabled." | ||
|
|
||
| To avoid this: | ||
|
|
||
| * Call `UseSpaceResolution()` before any middleware that uses Data Protection. | ||
| * Run background work inside `ISpaceContextAccessor.SetSpace(...)`. | ||
|
|
||
| ## Default Space Fallback | ||
|
|
||
| Values protected before you enabled partitioning use the unpartitioned purpose chain. To keep those values readable, | ||
| Spaces retries a failed unprotect in the Default space: | ||
|
|
||
| * When unprotecting fails with a `CryptographicException` in the Default space, Spaces retries with the unpartitioned | ||
| purpose chain. | ||
| * The fallback only applies to reads. Spaces always protects new values with the partitioned purpose chain. | ||
| * The fallback never applies to the Management space or to named spaces. | ||
|
|
||
| Each successful fallback increments the `duende.spaces.data_protection.default_space_fallback` counter on the | ||
| `Duende.Spaces` meter. Use it to see whether values protected before partitioning are still being read. | ||
|
|
||
| Never use the same purpose chain through both `GetUnpartitioned()` and the partitioned provider. In the Default space, | ||
| the fallback would accept the unpartitioned value. Spaces doesn't check for this. | ||
|
|
||
| ## Which Providers Are Partitioned | ||
|
|
||
| Spaces only partitions the non-keyed `IDataProtectionProvider` registration. These are not partitioned: | ||
|
|
||
| * Keyed `IDataProtectionProvider` registrations. | ||
| * Providers assigned to an authentication scheme's options, such as | ||
| `CookieAuthenticationOptions.DataProtectionProvider`. | ||
|
|
||
| Register the provider once, as a singleton, before you call `AddSpaces`. `UseSpaceResolution()` throws at startup when | ||
| the provider was registered or replaced after `AddSpaces`, or when more than one provider is registered. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.