Search code examples
asp.net-coreasp.net-identityidentityserver4

IdentityServer4 with persistent database


I'm trying to use IdentityServer4 with persistent database. I have an Oracle db. I'm planning on Extending the ConfigurationDbContext and PersistedGrantDbContext in order to do some oracle specific customization.

PersistedGrantDbContext

 public class IdentityPersistedGrantDbContext : PersistedGrantDbContext {
    public IdentityPersistedGrantDbContext(DbContextOptions<PersistedGrantDbContext> options, OperationalStoreOptions storeOptions)
         : base(options, storeOptions) {
    }
}

ConfigurationDbContext

public class IdentityConfigurationDbContext : ConfigurationDbContext {
    public IdentityConfigurationDbContext(DbContextOptions<ConfigurationDbContext> options, ConfigurationStoreOptions storeOptions)
         : base(options, storeOptions) {
    }
}

In the startup class, I do I tell the IdentityServer to use the custom classes?


Solution

  • Implement IPersistedGrantStore as seen here. And add it to the ASP.NET Core ServiceCollection (aka the DI container).

    eg:

            services.AddTransient<IPersistedGrantStore, MyPersistedGrantStore>();
    

    where MyPersistedGrantStore uses that DbContext to do those CRUD operations as defined in the interface/contract.