Create SQL XmlRepository
Closed this issue · 3 comments
janpieterz commented
Would make sense as it's one of the most common shared pieces of infrastructure between multiple servers.
It's mentioned in #145 but doesn't seem to have been built.
blowdart commented
@muratg It's worth doing, but I think trying to make it generic, or indeed EF model based might be more bother than its worth. A straightforward SQL, with parameterised queries would do it.
urbanhusky commented
I'm trying to implement such a repository and I use EF. I struggle with figuring out how to properly resolve the corresponding DbContext
. The context would be registered as scoped in the DI container, but I don't know how the repository is being registered - or if I would have to register it myself.
I do the following:
// Register db context
services.AddDbContext<DataProtectionDbContext>(
opts =>
{
var dpapiMigrationsAssembly = typeof(DataProtectionDbContext).GetTypeInfo().Assembly.GetName().Name;
opts.UseSqlServer(dpapiConnectionString, b => b.MigrationsAssembly(dpapiMigrationsAssembly));
});
// configure dpapi
services.AddDataProtection()
.ProtectKeysWithCertificate(GetCertificate()) // no support for rollover or revocation when using certificate?
.AddKeyManagementOptions(options => options.XmlRepository = new SqlDatabaseXmlRepository(/* TODO: how to resolve? Repository needs to be an instance and any DI would be for *right now* */))
aspnet-hello commented
This issue was moved to dotnet/aspnetcore#2505