Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aguafrommars/identity.redis
ASP.NET Identity Redis Provider
https://github.com/aguafrommars/identity.redis
asp-net-core identity redis
Last synced: 29 days 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 (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-29T06:28:58.000Z (8 months ago)
- Last Synced: 2024-05-02T06:00:40.884Z (8 months ago)
- Topics: asp-net-core, identity, redis
- Language: C#
- Homepage:
- Size: 22.3 MB
- Stars: 34
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
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[![Build status](https://ci.appveyor.com/api/projects/status/tmh3ib2s64ay2sc7?svg=true)](https://ci.appveyor.com/project/aguacongas/identity-redis)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=aguacongas_Identity.Redis&metric=alert_status)](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.