Skip to content
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

Create SQL XmlRepository for storing Data Protection keys #2505

Closed
aspnet-hello opened this issue Jan 1, 2018 · 5 comments
Closed

Create SQL XmlRepository for storing Data Protection keys #2505

aspnet-hello opened this issue Jan 1, 2018 · 5 comments
Assignees
Labels
area-dataprotection Includes: DataProtection Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one

Comments

@aspnet-hello
Copy link

From @janpieterz on Saturday, October 7, 2017 8:02:51 AM

Would make sense as it's one of the most common shared pieces of infrastructure between multiple servers.

It's mentioned in aspnet/DataProtection#145 but doesn't seem to have been built.

Copied from original issue: aspnet/DataProtection#280

@aspnet-hello aspnet-hello added enhancement This issue represents an ask for new feature or an enhancement to an existing one area-dataprotection Includes: DataProtection labels Jan 1, 2018
@aspnet-hello
Copy link
Author

From @blowdart on Friday, October 13, 2017 11:58:42 AM

@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.

@aspnet-hello
Copy link
Author

From @urbanhusky on Monday, November 27, 2017 12:46:54 AM

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* */))

@dansward
Copy link
Contributor

I have an EntityFrameworkCore implementation of this along with tests and a sample ready for review. Please let me know if it is ok to submit a pull request.

@natemcmaster
Copy link
Contributor

@dansward thanks for your PR to kick off the conversation on this subject.

We would be interested in taking a well-written PR to create this feature. At minimum, we would hope to see an implementation that satisfies the following:

  • There is a way for users to create the expected database schema.
  • There is a way for users to configure the repository by providing a connection string
  • There is a way for users to change between database providers, such as SQL Server or Postgres.

These requirements are pretty high-level, so let's have a conversation about the options for implementing these. One option includes using Entity Framework Core, but that is not the only alternative.

@natemcmaster
Copy link
Contributor

natemcmaster pushed a commit that referenced this issue Nov 15, 2018
- Required to log long-running tests
- Will help investigate aspnet/KestrelHttpServer#2503
natemcmaster pushed a commit that referenced this issue Nov 15, 2018
- xUnit diagnostic messages were enabled in #2505 to help identify hung tests
- However, this also enables log messages for non-serializable theory data (aspnet/KestrelHttpServer#2509), which adds noise to logs
- It doesn't seem possible to disable the "non-serializable data" messages but keep the "long-running test" messages
- Converting all tests to serializable theory data is expensive and complicates test code
- The best solution for now is to revert xUnit diagnostic messages to disabled, and re-enable when needed to identify hung tests
ryanbrandenburg pushed a commit that referenced this issue Nov 27, 2018
…-master

[automated] Merge branch 'release/2.2' => 'master'
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-dataprotection Includes: DataProtection Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one
Projects
None yet
Development

No branches or pull requests

4 participants