Ntk8 4.0.3

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.
<PackageVersion Include="Ntk8" Version="4.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Ntk8" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ntk8 --version 4.0.3
                    
#r "nuget: Ntk8, 4.0.3"
                    
#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.
#:package Ntk8@4.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ntk8&version=4.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Ntk8&version=4.0.3
                    
Install as a Cake Tool

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 249 8/25/2022
5.0.5-alpha 259 8/13/2022
5.0.4-alpha 268 7/28/2022
5.0.3-alpha 245 7/28/2022
5.0.2-alpha 256 7/23/2022
5.0.1-alpha 237 7/23/2022
5.0.0-alpha 246 7/23/2022
4.0.3 637 6/14/2022
4.0.2 625 5/26/2022
4.0.1 626 5/26/2022
4.0.0 604 5/26/2022
3.0.5 662 5/7/2022
3.0.4 628 5/7/2022
3.0.3 626 5/5/2022
3.0.2 644 4/16/2022
3.0.1 632 4/10/2022
3.0.0 664 4/10/2022
2.0.0.14-beta 263 2/14/2022
2.0.0.13-beta 251 2/13/2022
2.0.0.12-beta 248 2/6/2022
2.0.0.11-beta 277 1/25/2022
2.0.0.10-beta 371 12/12/2021
2.0.0.9-beta 290 12/7/2021
2.0.0.8-beta 307 12/6/2021
2.0.0.7-beta 304 12/6/2021
2.0.0.6-beta 280 12/6/2021
2.0.0.5-beta 310 12/6/2021
2.0.0.4-beta 2,862 11/24/2021
2.0.0.3-beta 6,619 11/23/2021
2.0.0.2-beta 308 11/16/2021
2.0.0.1-beta 345 11/14/2021
2.0.0-beta 375 11/14/2021
1.0.2 539 9/8/2021
1.0.1 648 9/7/2021 1.0.1 is deprecated because it has critical bugs.
1.0.0 694 7/25/2021 1.0.0 is deprecated because it has critical bugs.

Upgrade deps on dapper.cqrs