Dustin
Dustin

Reputation: 735

Is it possible to use a NoSQL for Identity Server 4?

I'm trying to integrate a NoSql data store into Identity Server 4 such as Cosmos DB. I was wondering if someone out there has done something similar and/or if it's possible.

Upvotes: 15

Views: 4659

Answers (2)

Gopinath
Gopinath

Reputation: 266

The above answer is working but a bit old. As of Sept 2021, I have implemented the same by registering custom stores directly in IdentityServer() pipeline.

By default, these custom implementations will get registered with Transient lifetime. In my case, MongoDB has been used, so that implemented custom stores to read Identity data from NoSQL collections.

services.AddIdentityServer()
                .AddAspNetIdentity<ApplicationUser>()            
                .AddClientStore<CustomClientStore>()
                .AddCorsPolicyService<InMemoryCorsPolicyService>()
                .AddResourceStore<CustomResourceStore>()
                .AddPersistedGrantStore<CustomPersistedGrantStore>()
                .AddDeveloperSigningCredential();

Upvotes: 0

MJK
MJK

Reputation: 3514

Off-course, It is possible to use NoSQL database for IdentityServer4. Why not?

Here is an example with MongoDB

"initial plumbing" in ConfigureServices() method at startup.cs.

 public void ConfigureServices(IServiceCollection services)
  { 
  ...
    // ---  configure identity server with MONGO Repository for stores, keys, clients and scopes ---
    services.AddIdentityServer()
           .AddTemporarySigningCredential()
           .AddMongoRepository()
           .AddClients()
           .AddIdentityApiResources()
           .AddPersistedGrants()
           .AddTestUsers(Config.GetUsers());
  ...
  }

There is another github project cloudscribe, ASP.NET Core multi-tenant web application foundation with management for sites, users, roles, claims and more. This project is implementing PostgreSQL (ORDBMS) and MySql for IdentityServer. In this project, you can get the idea about how to implement a system that allows switching among databases.

Upvotes: 7

Related Questions