All Projects → grandchamp → Identity.dapper

grandchamp / Identity.dapper

Licence: mit
Identity package that uses Dapper instead EntityFramework for use with .NET Core

Projects that are alternatives of or similar to Identity.dapper

Awesome Microservices Netcore
💎 A collection of awesome training series, articles, videos, books, courses, sample projects, and tools for Microservices in .NET Core
Stars: ✭ 865 (+269.66%)
Mutual labels:  aspnetcore, aspnet-core, aspnet, dotnetcore
ChatService
ChatService (SignalR).
Stars: ✭ 26 (-88.89%)
Mutual labels:  aspnetcore, dotnetcore, aspnet-core
React Core Boilerplate
Powerful ASP.NET Core 3 templates with React, true server-side rendering and Docker support
Stars: ✭ 169 (-27.78%)
Mutual labels:  aspnetcore, aspnet-core, aspnet
Identityserver4aspnetcoreidentitytemplate
An ASP.NET Core 3.1 IdentityServer4 Identity Bootstrap 4 template with localization
Stars: ✭ 262 (+11.97%)
Mutual labels:  aspnetcore, aspnet-core, identity
Architecture
.NET 6, ASP.NET Core 6, Entity Framework Core 6, C# 10, Angular 13, Clean Code, SOLID, DDD.
Stars: ✭ 2,285 (+876.5%)
Mutual labels:  aspnetcore, aspnet-core, dotnetcore
abp-push
Push Notification System for ASP.NET Boilerplate
Stars: ✭ 16 (-93.16%)
Mutual labels:  aspnetcore, aspnet, aspnet-core
awesome-dotnet-async
A curated list of awesome articles and resources to learning and practicing about async, threading, and channels in .Net platform. 😉
Stars: ✭ 84 (-64.1%)
Mutual labels:  aspnetcore, dotnetcore, aspnet-core
AspNetCore.Identity.RavenDB
RavenDB Storage Provider for ASP.NET Core Identity
Stars: ✭ 16 (-93.16%)
Mutual labels:  identity, aspnetcore, aspnet
Aspnetcore Practice
ASP.NET Core 專案練習集合,ASP.NET Core Practice Projects
Stars: ✭ 80 (-65.81%)
Mutual labels:  aspnet-core, dapper, dotnetcore
Aspnetcore.identity.mongodb
MongoDB Data Store Adaptor for ASP.NET Core Identity
Stars: ✭ 210 (-10.26%)
Mutual labels:  aspnetcore, aspnet, identity
aspnet-core-3-basic-authentication-api
ASP.NET Core 3.1 - Basic HTTP Authentication API
Stars: ✭ 70 (-70.09%)
Mutual labels:  aspnetcore, aspnet, dotnetcore
Aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
Stars: ✭ 10,061 (+4199.57%)
Mutual labels:  aspnetcore, aspnet-core, aspnet
Huxley2
A cross-platform JSON proxy for the GB railway Live Departure Boards SOAP API
Stars: ✭ 22 (-90.6%)
Mutual labels:  aspnetcore, dotnetcore, aspnet-core
AspNetCoreAzureSearch
ASP.NET Core with Azure Cognitive Search
Stars: ✭ 12 (-94.87%)
Mutual labels:  aspnetcore, dotnetcore, aspnet-core
Awesome-Nuget-Packages
📦 A collection of awesome and top .NET packages sorted by most popular needs.
Stars: ✭ 87 (-62.82%)
Mutual labels:  aspnetcore, dotnetcore, aspnet-core
Cosmos.Identity
A Cosmos storage provider for ASP.NET Core Identity.
Stars: ✭ 26 (-88.89%)
Mutual labels:  identity, aspnetcore, dotnetcore
GatewayService
GatewayService (Ocelot).
Stars: ✭ 19 (-91.88%)
Mutual labels:  aspnetcore, dotnetcore, aspnet-core
Aspnet5identityserverangularimplicitflow
OpenID Connect Code / Implicit Flow with Angular and ASP.NET Core 5 IdentityServer4
Stars: ✭ 670 (+186.32%)
Mutual labels:  aspnetcore, aspnet-core, identity
Aspnetcore.docs
Documentation for ASP.NET Core
Stars: ✭ 9,940 (+4147.86%)
Mutual labels:  aspnetcore, aspnet-core, aspnet
Cronscheduler.aspnetcore
Cron Scheduler for AspNetCore 2.x/3.x or DotNetCore 2.x/3.x Self-hosted
Stars: ✭ 100 (-57.26%)
Mutual labels:  aspnetcore, aspnet-core, dotnetcore

Identity.Dapper

Build Status NuGet

Find the corresponding NuGet package for your DBMS (Eg: Identity.Dapper.SqlServer).

To configure the DBMS connection, you can add a DapperIdentity and a DapperIdentityCryptography section to your configuration file like this:

"DapperIdentity": {
    "ConnectionString": "Connection string of your database",
    "Username": "user",
    "Password": "123"
},
"DapperIdentityCryptography": {
    "Key": "Base64 32 bytes key",
    "IV": "Base64 16 bytes key"
}

Example:
Key: "E546C8DF278CD5931069B522E695D4F2" (32 Bytes)
Base64 Encoded Key: "RTU0NkM4REYyNzhDRDU5MzEwNjlCNTIyRTY5NUQ0RjI="

IV: "SomeReallyCoolIV" (16 Bytes)
Base64 Encoded IV: "U29tZVJlYWxseUNvb2xJVg=="

Alternatively, you can use ConnectionStrings default section:

"ConnectionStrings": {
    "DefaultConnection": "Connection string of your database"
}

Or you can use the User Secrets commands:

dotnet user-secrets set DapperIdentity:ConnectionString "Connection string of your database"
dotnet user-secrets set DapperIdentity:Password "123"
dotnet user-secrets set DapperIdentity:Username "user"

dotnet user-secrets set DapperIdentityCryptography:Key "Base64 32 bytes key"
dotnet user-secrets set DapperIdentityCryptography:IV "Base64 16 bytes key"

The DapperIdentity:Password can be encrypted with AES256 using the KEY and IV provided.

On Startup.cs file, go to ConfigureServices and add the following lines:

services.ConfigureDapperConnectionProvider<T>(Configuration.GetSection("DapperIdentity"))
        .ConfigureDapperIdentityCryptography(Configuration.GetSection("DapperIdentityCryptography"));

services.AddIdentity<DapperIdentityUser, DapperIdentityRole<int>>()
        .AddDapperIdentityFor<T>()
        .AddDefaultTokenProviders();

or

services.ConfigureDapperConnectionProvider<T>(Configuration.GetSection("ConnectionStrings"))

Where T for the method ConfigureDapperConnectionProvider is DBMSNameConnectionProvider (eg: SqlServerConnectionProvider) and T for the method AddDapperIdentityFor is DBMSNameConfiguration (eg: SqlServerConfiguration).

If you want to use Transactions to all methods of Identity, you'll have to add .ConfigureDapperIdentityOptions(new DapperIdentityOptions { UseTransactionalBehavior = true }) below ConfigureDapperIdentityCryptography(Configuration.GetSection("DapperIdentityCryptography"));

And inside your controller, you'll have to insert on constructor a DapperUserStore<TUser, TKey, TUserRole, TRoleClaim, TUserClaim, TUserLogin, TRole> variable, like this:

private readonly DapperUserStore<CustomUser, int, DapperIdentityUserRole<int>, DapperIdentityRoleClaim<int>, DapperIdentityUserClaim<int>, DapperIdentityUserLogin<int>, CustomRole> _dapperStore;

...

 public ManageController(IUserStore<CustomUser> dapperStore)
        {
            _dapperStore = dapperStore as DapperUserStore<CustomUser, int, DapperIdentityUserRole<int>, DapperIdentityRoleClaim<int>, DapperIdentityUserClaim<int>, DapperIdentityUserLogin<int>, CustomRole>;
        }

And after all operations, you'll have to call DapperUserStore.SaveChanges() method, otherwise your changes will be rollbacked.

Currently, only SQL Server, PostgreSQL and MySQL are supported. We plan support for Oracle when the company release the .NET Core version for their System.Data implementation.

Using Guid as Entity key

Specify the

services.AddIdentity<DapperIdentityUser<Guid>, DapperIdentityRole<Guid>>()
        .AddDapperIdentityFor<T, Guid>();

Changing the default schema (SqlServer)

Pass a custom class that inherits from SqlServerConfiguration (or other)

public class CustomSqlServerConfiguration : SqlServerConfiguration
{
    public CustomSqlServerConfiguration()
    {
        base.SchemaName = "[customSchema]";
    }
}

And add it with

services.AddDapperIdentityFor<CustomSqlServerConfiguration>()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].