Ntk8 4.0.3

.NET Standard 2.1
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Ntk8 --version 4.0.3
NuGet\Install-Package Ntk8 -Version 4.0.3
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="Ntk8" Version="4.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ntk8 --version 4.0.3
#r "nuget: Ntk8, 4.0.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Ntk8 as a Cake Addin
#addin nuget:?package=Ntk8&version=4.0.3

// Install Ntk8 as a Cake Tool
#tool nuget:?package=Ntk8&version=4.0.3

Ntk8

AuthNTk8 (auth-en-ti-cate) is a standalone .NET auth service for stateless authentication.

Main Features

Allows you to quickly throw together some authentication for a greenfield project.

Registration

webHost.ConfigureServices(config =>
    {
        config.AddTransient<IHttpContextAccessor, HttpContextAccessor>();
        config.AddTransient<AuthenticationContextService>();
        config.AddTransient<IBaseSqlExecutorOptions>(provider => new BaseSqlExecutorOptions
        {
            Connection = Resolve<IDbConnection>(),
            Dbms = DBMS.MySQL,
            ServiceProvider = provider
        });
        config.AddTransient<IAccountService, AccountService>();
        config.Configure<IAuthSettings>(options => appSettings.GetSection("AuthSettings").Bind(options));
    });

Usage

[ApiController]
[Route("")]
public class MainController
{
    
}

Account Service Interface

 public interface IAccountService
    {
        AuthenticateResponse Authenticate(AuthenticateRequest model, string ipAddress);
        AuthenticateResponse RefreshToken(string token, string ipAddress);
        void RevokeToken(string token, string ipAddress);
        void Register(RegisterRequest model, string origin);
        void VerifyEmail(string token);
        void ForgotPassword(ForgotPasswordRequest model, string origin);
        void ValidateResetToken(ValidateResetTokenRequest model);
        void ResetPassword(ResetPasswordRequest model);
        AccountResponse GetById(int id);
        AccountResponse Create(CreateRequest model);
        AccountResponse Update(int id, UpdateRequest model);
        void Delete(int id);
        void AutoVerifyUser(RegisterRequest model);
    }

Migration Scripts to create valid tables

These migrations are for mysql, some minor tweaking would be required for other databases.

As long as the properties match you will be able to use the package.

CREATE TABLE users
(
    id                  int PRIMARY KEY AUTO_INCREMENT,
    reference_id        char(36),
    title               varchar(20),
    email               varchar(60),
    first_name          varchar(100),
    last_name           varchar(100),
    tel_number          varchar(20),
    username            varchar(20),
    access_failed_count int,
    lockout_enabled     tinyint(1),
    password_hash       varchar(255),
    concurrency_stamp   varchar(255),
    security_stamp      varchar(255),
    password_salt       varchar(255),
    accepted_terms      tinyint(1),
    reset_token         varchar(100),
    verification_token  varchar(100),
    verification_date   datetime,
    password_reset_date datetime,
    reset_token_expires datetime,
    date_created        datetime,
    date_modified       datetime,
    is_active           tinyint(1)
);
CREATE TABLE roles
(
    id int PRIMARY KEY AUTO_INCREMENT,
    role_name varchar(50)
);
CREATE TABLE user_roles
(
    id      int PRIMARY KEY AUTO_INCREMENT,
    user_id int,
    role_id int
);
ALTER TABLE user_roles
    ADD CONSTRAINT user_roles_user_id
        FOREIGN KEY (user_id)
            REFERENCES users (id);

ALTER TABLE user_roles
    ADD CONSTRAINT user_roles_role_id
        FOREIGN KEY (role_id)
            REFERENCES roles (id);
CREATE TABLE IF NOT EXISTS refresh_tokens
(
	id bigint auto_increment
		primary key,
	user_id int null,
	token varchar(100) null,
	expires datetime null,
	is_expired tinyint(1) null,
	date_created datetime null,
	created_by_ip varchar(30) null,
	date_revoked datetime null,
	revoked_by_ip varchar(30) null,
	replaced_by_token varchar(100) null,
	is_active tinyint(1) null,
	CONSTRAINT refresh_tokens_user_id
		FOREIGN KEY (user_id) REFERENCES users (id)
);

Grab on nuget

CLI

dotnet add package Ntk8 --version 1.0.2

Nuget Package Manager

Install-Package Ntk8 -Version 1.0.2
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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
5.0.6-alpha 60 8/25/2022
5.0.5-alpha 75 8/13/2022
5.0.4-alpha 75 7/28/2022
5.0.3-alpha 72 7/28/2022
5.0.2-alpha 69 7/23/2022
5.0.1-alpha 61 7/23/2022
5.0.0-alpha 70 7/23/2022
4.0.3 309 6/14/2022
4.0.2 316 5/26/2022
4.0.1 320 5/26/2022
4.0.0 316 5/26/2022
3.0.5 351 5/7/2022
3.0.4 338 5/7/2022
3.0.3 344 5/5/2022
3.0.2 367 4/16/2022
3.0.1 346 4/10/2022
3.0.0 359 4/10/2022
2.0.0.14-beta 79 2/14/2022
2.0.0.13-beta 76 2/13/2022
2.0.0.12-beta 73 2/6/2022
2.0.0.11-beta 87 1/25/2022
2.0.0.10-beta 211 12/12/2021
2.0.0.9-beta 106 12/7/2021
2.0.0.8-beta 105 12/6/2021
2.0.0.7-beta 106 12/6/2021
2.0.0.6-beta 104 12/6/2021
2.0.0.5-beta 105 12/6/2021
2.0.0.4-beta 2,688 11/24/2021
2.0.0.3-beta 6,451 11/23/2021
2.0.0.2-beta 131 11/16/2021
2.0.0.1-beta 161 11/14/2021
2.0.0-beta 176 11/14/2021
1.0.2 322 9/8/2021
1.0.1 361 9/7/2021
1.0.0 403 7/25/2021

Upgrade deps on dapper.cqrs