https://github.com/aguafrommars/identity.redis
ASP.NET Identity Redis Provider
https://github.com/aguafrommars/identity.redis
asp-net-core identity redis
Last synced: 1 day ago
JSON representation
ASP.NET Identity Redis Provider
- Host: GitHub
- URL: https://github.com/aguafrommars/identity.redis
- Owner: Aguafrommars
- License: apache-2.0
- Created: 2018-03-07T17:49:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-07-09T06:36:06.000Z (6 days ago)
- Last Synced: 2025-07-09T07:40:40.234Z (6 days ago)
- Topics: asp-net-core, identity, redis
- Language: C#
- Homepage:
- Size: 22.4 MB
- Stars: 37
- Watchers: 1
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Identity.Redis
[ASP.NET Identity](https://github.com/aspnet/AspNetCore/tree/master/src/Identity) Redis Provider[](https://ci.appveyor.com/project/aguacongas/identity-redis)
[](https://sonarcloud.io/dashboard?id=aguacongas_Identity.Redis)Nuget packages
--------------
|Aguacongas.Identity.Redis|
|:------:|
|[![][Aguacongas.Identity.Redis-badge]][Aguacongas.Identity.Redis-nuget]|
|[![][Aguacongas.Identity.Redis-downloadbadge]][Aguacongas.Identity.Redis-nuget]|[Aguacongas.Identity.Redis-badge]: https://img.shields.io/nuget/v/Aguacongas.Identity.Redis.svg
[Aguacongas.Identity.Redis-downloadbadge]: https://img.shields.io/nuget/dt/Aguacongas.Identity.Redis.svg
[Aguacongas.Identity.Redis-nuget]: https://www.nuget.org/packages/Aguacongas.Identity.Redis/## Setup
You setup Redis stores using one `AddRedisStores` extension method
You can setup Redis stores with a redis configuration string:
services.AddIdentity()
.AddRedisStores("localhost")
.AddDefaultTokenProviders();Or with an `Action` receiving an instance of a `StackExchange.Redis.ConfigurationOptions`:
services.AddIdentity()
.AddRedisStores(options =>
{
options.EndPoints.Add("localhost:6379");
})
.AddDefaultTokenProviders();Both methods can take a `int? database` parameter to specify the Redis database to use:
services.AddIdentity()
.AddRedisStores(Configuration.GetValue("ConnectionStrings:DefaultConnection"), 1)
.AddDefaultTokenProviders();Or, you can use `AddRedisStores` with a `Func`:
var multiplexer = ConnectionMultiplexer.Connect("localhost");
services.AddIdentity()
.AddRedisStores(provider => multiplexer.GetDatabase())
.AddDefaultTokenProviders();### Logging
A logger is automaticaly injected to the underlying `StackExchange.Redis.ConnectionMultiplexer` by `AddRedisStores` methods.
This logger write traces, (LogLevel = `LogLevel.Trace`), to enable it add a filter to your logging configuration:services.AddLogging(builder =>
{
builder.AddDebug()
.AddConsole()
.AddFilter("Aguacongas.Identity.Redis", LogLevel.Trace);
})> Obviously, if you use `AddRedisStores` with a `Func` the logger is not injected automaticaly.
## Sample
The sample is a copy of [IdentitySample.Mvc](https://github.com/aspnet/Identity/tree/dev/samples/IdentitySample.Mvc) sample using a Redis database.
## Tests
This library is tested using [Microsoft.AspNetCore.Identity.Specification.Tests](https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.Specification.Tests/), the shared test suite for Asp.Net Identity Core store implementations.