Refactor DI support in DataProtection
ajaybhargavb opened this issue · 10 comments
@ajaybhargavb How close is this for check-in?
@Eilon Are we taking this in RC2? Or postpone to 1.0.0?
I'll be sending an update to the PR today. But it will not include and test and documentation changes.
I'd like to get this for RC2 because there are public API changes in it, and I spoke to @ajaybhargavb about it and we had a short email thread too.
Looks like the PR is a little stale at the moment. Do we have any blockers on this?
The latest code and samples are in https://github.com/aspnet/DataProtection/tree/ajbaaska/new-dataprotection branch.
@ajaybhargavb You're working on the DI bits, right? I ask because I was having a small problem with DI into the XmlDecryptor
. #154
The problem was that DI for XmlDecryptor
wasn't working. I wanted to do this ...
public CustomXmlDecryptor(IOptions<CustomDataProtectionOptions> dataProtectionOptions)
{
_key = dataProtectionOptions.Value.Key;
}
... but that wasn't working. I simply wasn't getting the value. It works using the ctor injection pattern for XmlEncryptor
, just not for XmlDecryptor
.
With a little help from @tillig, I was able to make it work on the decryptor side with a little hack, I ended up having to do this ...
public CustomXmlDecryptor(IServiceProvider services)
{
var dataProtectionOptions =
services.GetRequiredService<IOptions<CustomDataProtectionOptions>>();
_key = dataProtectionOptions.Value.Key;
}
Is fixing this something that falls under this issue, or was this problem already addressed do you know?