Ntk8 3.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ntk8 --version 3.0.4
NuGet\Install-Package Ntk8 -Version 3.0.4
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="3.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ntk8 --version 3.0.4
#r "nuget: Ntk8, 3.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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=3.0.4

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

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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 160 8/25/2022
5.0.5-alpha 165 8/13/2022
5.0.4-alpha 174 7/28/2022
5.0.3-alpha 153 7/28/2022
5.0.2-alpha 161 7/23/2022
5.0.1-alpha 148 7/23/2022
5.0.0-alpha 153 7/23/2022
4.0.3 515 6/14/2022
4.0.2 533 5/26/2022
4.0.1 527 5/26/2022
4.0.0 497 5/26/2022
3.0.5 540 5/7/2022
3.0.4 525 5/7/2022
3.0.3 532 5/5/2022
3.0.2 557 4/16/2022
3.0.1 533 4/10/2022
3.0.0 560 4/10/2022
2.0.0.14-beta 179 2/14/2022
2.0.0.13-beta 152 2/13/2022
2.0.0.12-beta 161 2/6/2022
2.0.0.11-beta 189 1/25/2022
2.0.0.10-beta 284 12/12/2021
2.0.0.9-beta 189 12/7/2021
2.0.0.8-beta 212 12/6/2021
2.0.0.7-beta 193 12/6/2021
2.0.0.6-beta 176 12/6/2021
2.0.0.5-beta 197 12/6/2021
2.0.0.4-beta 2,761 11/24/2021
2.0.0.3-beta 6,518 11/23/2021
2.0.0.2-beta 221 11/16/2021
2.0.0.1-beta 246 11/14/2021
2.0.0-beta 277 11/14/2021
1.0.2 433 9/8/2021
1.0.1 485 9/7/2021
1.0.0 521 7/25/2021

Pre-release of version 2.0.0.