Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vborovikov/identity

ASP.NET Core Identity storage providers that use Dapper
https://github.com/vborovikov/identity

aspnetcore aspnetcore-identity dapper mysql postgresql sql-server sqlite

Last synced: about 2 months ago
JSON representation

ASP.NET Core Identity storage providers that use Dapper

Awesome Lists containing this project

README

        

# Spryer.AspNetCore.Identity
ASP.NET Core Identity storage providers that use Dapper.

## Packages

| Package | Version | Downloads |
| --- | --- | --- |
| [Spryer](https://github.com/vborovikov/spryer) | [![NuGet](https://img.shields.io/nuget/v/Spryer.svg)](https://www.nuget.org/packages/Spryer) | [![Downloads](https://img.shields.io/nuget/dt/Spryer.svg)](https://www.nuget.org/packages/Spryer) |
| Spryer.AspNetCore.Identity | [![NuGet](https://img.shields.io/nuget/v/Spryer.AspNetCore.Identity.svg)](https://www.nuget.org/packages/Spryer.AspNetCore.Identity) | [![Downloads](https://img.shields.io/nuget/dt/Spryer.AspNetCore.Identity.svg)](https://www.nuget.org/packages/Spryer.AspNetCore.Identity) |
| Spryer.AspNetCore.Identity.SqlServer | [![NuGet](https://img.shields.io/nuget/v/Spryer.AspNetCore.Identity.SqlServer.svg)](https://www.nuget.org/packages/Spryer.AspNetCore.Identity.SqlServer) | [![Downloads](https://img.shields.io/nuget/dt/Spryer.AspNetCore.Identity.SqlServer.svg)](https://www.nuget.org/packages/Spryer.AspNetCore.Identity.SqlServer) |
| Spryer.AspNetCore.Identity.Sqlite | [![NuGet](https://img.shields.io/nuget/v/Spryer.AspNetCore.Identity.Sqlite.svg)](https://www.nuget.org/packages/Spryer.AspNetCore.Identity.Sqlite) | [![Downloads](https://img.shields.io/nuget/dt/Spryer.AspNetCore.Identity.Sqlite.svg)](https://www.nuget.org/packages/Spryer.AspNetCore.Identity.Sqlite) |

## Usage

```csharp
public sealed class AppUser : IdentityUser
{
public AppUser()
{
// default Identity UI uses this ctor when registering new users
this.Id = Guid.NewGuid();
this.SecurityStamp = Guid.NewGuid().ToString();
}
}

public sealed class AppRole : IdentityRole
{
public AppRole()
{
// default Identity UI uses this ctor when creating new roles
this.Id = Guid.NewGuid();
}
}

// Program.cs

var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ??
throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");

builder.Services.AddSingleton(_ => SqlClientFactory.Instance.CreateDataSource(connectionString));

builder.Services
.AddIdentity(options => options.SignIn.RequireConfirmedAccount = true)
.AddDapperStores(options =>
{
options.UseSqlServer();
})
.AddDefaultUI()
.AddDefaultTokenProviders();
```