Skip to content

Latest commit

 

History

History
66 lines (50 loc) · 2.51 KB

README.md

File metadata and controls

66 lines (50 loc) · 2.51 KB

Oogi2.AspNetCore3.Identity

Oogi2.AspNetCore3.Identity

Software License Latest Version on NuGet NuGet Visual Studio Team services netcoreapp6.0

ASP.NET Core 6.0 Identity with DocumentDB (CosmosDB) as database layer. It is powered by Oogi2. It's special fork that targets ASP.NET Core 6.0.

Configuration

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.

Acknowledgement

Based on AspNetCore.Identity.DocumentDb by codekoenig

License

MIT © frohikey / Goto10 s.r.o.