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.
Install-Package Ntk8 -Version 4.0.3
dotnet add package Ntk8 --version 4.0.3
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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
.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.5-alpha 42 8/13/2022
5.0.4-alpha 49 7/28/2022
5.0.3-alpha 45 7/28/2022
5.0.2-alpha 47 7/23/2022
5.0.1-alpha 39 7/23/2022
5.0.0-alpha 46 7/23/2022
4.0.3 86 6/14/2022
4.0.2 93 5/26/2022
4.0.1 95 5/26/2022
4.0.0 89 5/26/2022
3.0.5 117 5/7/2022
3.0.4 109 5/7/2022
3.0.3 118 5/5/2022
3.0.2 147 4/16/2022
3.0.1 122 4/10/2022
3.0.0 131 4/10/2022
2.0.0.14-beta 62 2/14/2022
2.0.0.13-beta 56 2/13/2022
2.0.0.12-beta 56 2/6/2022
2.0.0.11-beta 69 1/25/2022
2.0.0.10-beta 194 12/12/2021
2.0.0.9-beta 85 12/7/2021
2.0.0.8-beta 87 12/6/2021
2.0.0.7-beta 87 12/6/2021
2.0.0.6-beta 88 12/6/2021
2.0.0.5-beta 87 12/6/2021
2.0.0.4-beta 2,668 11/24/2021
2.0.0.3-beta 6,429 11/23/2021
2.0.0.2-beta 113 11/16/2021
2.0.0.1-beta 139 11/14/2021
2.0.0-beta 156 11/14/2021
1.0.2 251 9/8/2021
1.0.1 292 9/7/2021
1.0.0 333 7/25/2021

Upgrade deps on dapper.cqrs