-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Support key deletion in Data Protection #53860
Conversation
@@ -238,15 +238,36 @@ private static bool IsLogLevelEnabledCore([NotNullWhen(true)] ILogger? logger, L | |||
[LoggerMessage(60, LogLevel.Warning, "Storing keys in a directory '{path}' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning", EventName = "UsingEphemeralFileSystemLocationInContainer")] | |||
public static partial void UsingEphemeralFileSystemLocationInContainer(this ILogger logger, string path); | |||
|
|||
[LoggerMessage(61, LogLevel.Trace, "Ignoring configuration '{PropertyName}' for options instance '{OptionsName}'", EventName = "IgnoringReadOnlyConfigurationForNonDefaultOptions")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess 60 was missed, so it appears after 66, which seems to have confused whoever added the following items. Can I update these, given that they're wrong now?
I had to move to per-target-platform API manifests because DIM isn't available on framework. |
I'll add tests once the API is reviewed, but the shape has changed several times already. |
src/DataProtection/DataProtection/src/Repositories/RegistryXmlRepository.cs
Show resolved
Hide resolved
Force push is a rebase - I'll address API Review feedback separately. |
I also prepared a version where the key manager gets to return an ordered list of |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tratcher have you taken a look at this recently? Does it meet your needs?
src/DataProtection/DataProtection/src/Repositories/EphemeralXmlRepository.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Repositories/EphemeralXmlRepository.cs
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/KeyManagement/IDeletableKeyManager.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/KeyManagement/IDeletableKeyManager.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/KeyManagement/IDeletableKeyManager.cs
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Repositories/FileSystemXmlRepository.cs
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Repositories/IDeletableXmlRepository.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Repositories/RegistryXmlRepository.cs
Show resolved
Hide resolved
Co-authored-by: Chris Ross <[email protected]>
I'm definitely a little curious how my new tests could pass only on Windows. Investigating. Edit: Opening a file with |
The only way I could find to make FileSystemInfo.Delete throw was to remove write permission to the parent directory and we don't have enough hooks to do and undo that around a single file deletion attempt (i.e. it's all or none).
I found this while building a custom repository for Mongodb. One idea that may be to late, since you look like you are pretty far along. You could simplify this by just adding a DeleteElement(string keyid) to IXmlRepository. Then let devs developing their own repositories to create the delete code. DeleteElement() method could be fired by Data Protection using a TTL. A TTL could be added to every key automatically when its created. Since the minimum expiration that can be set to a Key is 7 days. Data Protection could check the TTL every 7 days and fire deletes for all the expired keys. TTL date could be (expired date + time to live length) = TTL. Time to live length could be a setting with a default of (expired date * 2). I would make it so that devs would have to turn this feature on too. |
@donnyv The reason we didn't add Having said that, it was certainly our intention that Unless we hear a lot of demand (feel free to open an issue to collect feedback), I don't think we're likely to add an automated TTL mechanism. Generally speaking, we recommend keys never be deleted, so we want doing so to be a very explicit action on the app author's part. |
Add the ability to delete keys to support #52916. The approach is more complicated than you'd expect to account for the fact that
IXmlRepository
offers only two (possibly slow) operations: enumerate and add - there's no random access.Deleting keys remains discouraged.
Fixes #53880