Skip to content

Aguafrommars/Identity.RavenDb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Identity.RavenDb

ASP.NET Identity RavenDb Provider

Build status Quality Gate Status

Nuget packages

Aguacongas.Identity.RavenDb

Setup

You setup RavenDb stores using one AddRavenDbStores extension method

You can setup RavenDb stores using the current IDocumentStore:

services.AddSingleton(p => new DocumentStore
{
    Urls = new[] { "https://a.ravendb.local" },
    Database = "Identity"
}.SetFindIdentityPropertyForIdentityModel() // REQUIRED, Identity model identifiers are not computed by the database but the store
.Initialize());
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
        .AddRavenDbStores(); 

Or with a Func<IServiceProvider, IDocumentStore> creating the IDocumentStore :

var documentStore = new DocumentStore
{
    Urls = new[] { "https://a.ravendb.local" },
    Database = "Identity"
}.SetFindIdentityPropertyForIdentityModel() // REQUIRED, Identity model identifiers are not computed by the database but the store
.Initialize();

services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
    .AddRavenDbStores(p => documentStore);

Both methods can take a string dataBase parameter to specify the RavenDb database to use:

services.AddIdentity<IdentityUser, IdentityRole>()
    .AddRedisStores(dataBase: "Identity")
    .AddDefaultTokenProviders();

Your user and role class must be IdentityUser and IdentityRole or derived.

Sample

The IdentitySample is a dotnet webapp with individual authentication using a RavenDb database.

Tests

This library is tested using Microsoft.AspNetCore.Identity.Specification.Tests, the shared test suite for Asp.Net Identity Core store implementations.