Skip to content

quicksln/LiteDB.Identity

Repository files navigation

LiteDB.Identity

🚀 Start a seamless authentication experience with LiteDB.Identity 🚀

The revolutionary implementation of ASP.NET Core Identity tailored for the LiteDB database engine. LiteDB.Identity will provide quick creation of login, registration, roles, claims, and token functionality for web applications.

💡This isn't just a tool - it's your passport to an efficient authentication experience. 💡

Latest versions supports:

  • LiteDB 5.0.21
  • .NET 9 (9.0.8)
  • .NETSTANDARD 2.1
  • Microsoft.Extensions.Identity.Core 9.0.8
  • Microsoft.Extensions.Identity.Stores 9.0.8

Support

If you have found my contributions to the projects helpful, consider buying me a coffee to fuel my efforts :)
Buy Me A Coffee

How to use it ?

Please install latest version of LiteDB.Identity using NuGet:

Install-Package LiteDB.Identity

For ASP.NET Core 8.0.11:

Install-Package LiteDB.Identity -Version 1.0.8.11

For ASP.NET Core 8.0.0:

Install-Package LiteDB.Identity -Version 1.0.8

Next, in your Startup.cs file add reference to namespace:

using LiteDB.Identity.Extensions;

Add default LiteDb.Identity implementation in Program.cs file:

For ASP.NET Core 9 :

using Microsoft.AspNetCore.Identity;
using LiteDB.Identity.Extensions;
using LiteDB.Identity.Models;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddLiteDBIdentity(connectionString);
builder.Services.AddDefaultIdentity<LiteDbUser>();

builder.Services.AddControllersWithViews();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    //app.UseMigrationsEndPoint();
}
else
{
    app.UseExceptionHandler("/Home/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapRazorPages();

app.Run();

NOTE: appsettings.json should contains connection string to your LiteDB file. For more implementation details please refer to sample project.

Stores implementation

Following interfaces has been implemented on :

  • UserStore :
    public class UserStore<TUser, TRole, TUserRole, TUserClaim, TUserLogin, TUserToken> : 
                                    IUserLoginStore<TUser>, 
                                    IUserStore<TUser>,
                                    IUserRoleStore<TUser>,
                                    IUserClaimStore<TUser>, 
                                    IUserPasswordStore<TUser>, 
                                    IUserSecurityStampStore<TUser>, 
                                    IUserEmailStore<TUser>, 
                                    IUserLockoutStore<TUser>, 
                                    IUserPhoneNumberStore<TUser>, 
                                    IQueryableUserStore<TUser>, 
                                    IUserTwoFactorStore<TUser>,
                                    IUserAuthenticationTokenStore<TUser>,
                                    IUserAuthenticatorKeyStore<TUser>,
                                    IUserTwoFactorRecoveryCodeStore<TUser>
  • RoleStore :
    public class RoleStore<TRole, TRoleClaim> : IQueryableRoleStore<TRole>, 
                                                IRoleStore<TRole>, 
                                                IRoleClaimStore<TRole>

Where to use it ?

  • Great for small and medium size website application based on:
    • ASP.NET Core MVC,
    • Blazor Server,
    • ASP.NET Core WebPages,
  • Quick implementation of Authentication and Authorization mechanism for WebAPIs.

References

License

MIT

About

ASP.NET Core Identity provider for LiteDB database engine.

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

Used by

Contributors

Languages