ASP.NET Core Identity with DocumentDB (CosmosDB) as database layer. It is powered by Oogi2.
public void ConfigureServices(IServiceCollection services)
{
var connection = new Connection
(
Configuration["endpoint"],
Configuration["authorizationKey"],
Configuration["database"],
Configuration["collection"]
);
services.AddSingleton<IConnection>(connection);
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddDocumentDbStores()
// I've prepared Czech localization
//.AddErrorDescriber<CzechIdentityErrorDescriber>()
// And English which is not needed... just for kicks
//.AddErrorDescriber<EnglishIdentityErrorDescriber>()
.AddDefaultTokenProviders();
}
If you don't need any own properties for user/role, you can just use IdentityUser
and IdentityRole
.
In our example we extended them with some funky properties:
[EntityType("entity", "oogi2/user")]
public class ApplicationUser : IdentityUser<ApplicationRole>
{
public int NumberOfNumbers { get; set; }
}
[EntityType("entity", "oogi2/role")]
public class ApplicationRole : IdentityRole
{
public bool IsClever { get; set; }
}
If you wanna know more about EntityType
attribute, check Oogi2.
And voila... that's all. EZPZ.
Based on AspNetCore.Identity.DocumentDb by codekoenig
MIT © frohikey / Goto10 s.r.o.