BetterRedisIdentity 1.0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package BetterRedisIdentity --version 1.0.0.2                
NuGet\Install-Package BetterRedisIdentity -Version 1.0.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BetterRedisIdentity" Version="1.0.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BetterRedisIdentity --version 1.0.0.2                
#r "nuget: BetterRedisIdentity, 1.0.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BetterRedisIdentity as a Cake Addin
#addin nuget:?package=BetterRedisIdentity&version=1.0.0.2

// Install BetterRedisIdentity as a Cake Tool
#tool nuget:?package=BetterRedisIdentity&version=1.0.0.2                

Better Redis Identity

While there are currently several projects available to connect and interface with Redis, I have found that they are not fully implemented/lack support or have critical bugs that make them unreliable.

🧐 Features

🛠️ Install Dependencies

nuget install BetterRedisIdentity

This will only work for a Redis Database that has Redis Search activated.

Important Information

Please review AsyncRedisDocuments to ensure you're familiar with how the ApplicationUser and ApplicationRole is expected to work. They are both IAsyncDocuments.

The following security information has moved from the user class to the user Security class, which can be accessed in the following manner:

await User.Security.Document.Roles.GetAsync();
  • LockoutEnabled
  • AccessFailedCount
  • LockoutEnd
  • PasswordHash
  • Claims
  • Logins
  • Roles
  • SecurityStamp
  • TwoFactorEnabled
  • AuthenticatorKey
  • AuthenticatorTokens
  • AuthenticatorRecoveryCodes

🧑🏻‍💻 Setup and Installation

First and and most importantly; initialize your redis singleton.

RedisSingleton.Initialize("host", port, "password");

Make sure your ApplicationUser enherits from RedisIdentityUser and your ApplicationRole inherits from RedisIdentityRole

    public class ApplicationUser : RedisIdentityUser
    public class ApplicationRole : RedisIdentityRole

Next up, add your stores.

builder.Services.AddRedisIdentityStores<ApplicationUser, ApplicationRole>();

If you need to use a custom user manager for your project, please ensure that you enherit from RedisUserManager<TUser> Our manager is necessary and is automatically included with AddRedisIdentityStores()

Setup your identity how you like.

builder.Services.AddIdentity<ApplicationUser, ApplicationRole>(options =>
{
    options.SignIn.RequireConfirmedAccount = false;
    options.User.RequireUniqueEmail = true;

}).AddDefaultTokenProviders() 
    .AddSignInManager(); 

Everything else forwards is pretty standard, include your authentication scheme and you should be all set.

builder.Services.AddAuthentication(options =>
{
    options.DefaultScheme = IdentityConstants.BearerScheme;
    options.DefaultSignInScheme = IdentityConstants.BearerScheme;
}).AddBearerToken();

Author

Bryly Maeder
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.3 69 2/10/2025
1.0.0.2 66 2/10/2025
1.0.0.1 60 2/10/2025
1.0.0 71 2/9/2025