Rask.Auth.Api 0.24.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Rask.Auth.Api --version 0.24.0
                    
NuGet\Install-Package Rask.Auth.Api -Version 0.24.0
                    
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="Rask.Auth.Api" Version="0.24.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rask.Auth.Api" Version="0.24.0" />
                    
Directory.Packages.props
<PackageReference Include="Rask.Auth.Api" />
                    
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 Rask.Auth.Api --version 0.24.0
                    
#r "nuget: Rask.Auth.Api, 0.24.0"
                    
#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 Rask.Auth.Api@0.24.0
                    
#: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=Rask.Auth.Api&version=0.24.0
                    
Install as a Cake Addin
#tool nuget:?package=Rask.Auth.Api&version=0.24.0
                    
Install as a Cake Tool

Rask.Auth.Api

Accounts as JSON endpoints, for an ASP.NET Core app that renders no Rask components — a plain ASP.NET app or API where something else owns the UI.

Register, sign in, sign out, /me, email confirmation and password reset, all at /api/auth, on the app's own User aggregate: PBKDF2 or bcrypt password hashing, a session row per signed-in device that signing out elsewhere or a password reset ends at once, throttling rather than lockout, and passkeys beside the password. The first account to register becomes the administrator.

builder.Services.AddRaskAuth<AppDbContext>();
builder.Services.AddAuthorization();

var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.MapRaskAuth();          // POST /register, /login, /logout — GET /me — plus the recovery flows

Map the tables in OnModelCreating and create the schema:

protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.AddRaskAuth();
rask db add AddAuth && rask db update

Declare the user type once, anywhere in the app — the generator finds it, and adding a column is adding a property:

public sealed class User : Authenticatable
{
    public string DisplayName { get; private set; } = "";
}

A users table keyed by text, whose people sign in by user name, keeps both — and its bcrypt hashes:

public sealed class User : Authenticatable<string>
{
    [SignInName] public Username Username { get; private set; }
}

An administrator manages the accounts of the tenant they work in — signing nobody in, and refused to anybody whose row lacks the admin role:

await Accounts.Create(name, password);
await Accounts.SetPassword(id, password);   // ends that user's sessions; blank leaves it
await Accounts.Remove(id);                  // with their sessions and passkeys

Which package

Rask.Auth.Api This one. The front end owns sign-in; the host answers /api/auth. No components, no renderer, no Rask.Core.
Rask.Auth The app is a Rask app. Everything here, plus a host-neutral IAuth for components; rask new writes the sign-in pages into the app.
Rask.Auth.Client The same flows called from a WebAssembly client.

Reference one of the first two, never both: Rask.Auth already contains this package.

Why it is separate

Rask — the core, with the renderer — is a dependency of the hosts that render components (Rask.Server, Rask.Wasm) and of nothing else, so a host that renders nothing ships no copy of it. A battery that needed Core could therefore not run on such a host at all: the assembly is simply absent and the app aborts before Main.

This package is the accounts battery with that dependency removed. It talks to the wire contract in Rask.Wire — the /api/auth paths, the request and response shapes, AuthResult — which the browser-side Rask.Auth.Client also takes, so both halves agree without either one carrying the renderer.

Bearer tokens

Cookies are the default and the right answer for anything running in a page. A non-browser caller opts in:

builder.Services.AddRaskAuth<AppDbContext>(o => o.Bearer = new BearerOptions { SigningKey = key });

Then send X-Rask-Auth-Mode: bearer alongside X-Rask-Auth and a sign-in answers with a token in the body — never a cookie, never a header, so nothing stores it on the caller's behalf.

Email

Confirmation and reset links go out through the app's own mail queue (Rask.Mail), so they survive a restart between "the account exists" and "the email went out". An app with no mail battery is told it cannot send a reset link rather than silently queueing one nowhere.


Part of Rask. Full documentation: https://rask.sh/docs/guides/authentication.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Rask.Auth.Api:

Package Downloads
Rask.Auth

Register, sign in and sign out for a Rask app, on by default. Accounts are the app's own User aggregate (PBKDF2 or bcrypt password hashing, passkeys beside the password, one revocable session row per signed-in device, sign-in throttling) and are exposed through Rask's own host-neutral surface — the same IUserProvider, Authorize component and [Authorize] routes work unchanged on the Server and WebAssembly hosts. rask new writes the /login, /register, /logout and /devices pages into the app, and the matching /api/auth endpoints serve the same flows over HTTP. Email confirmation and password reset go out through the app's own mail queue, with /confirm-email, /forgot-password and /reset-password pages scaffolded to match. The first account to register becomes the admin.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.24.1-alpha.0.987 32 11/28/2026
0.24.1-alpha.0.979 37 11/28/2026
0.24.1-alpha.0.972 43 11/28/2026
0.24.1-alpha.0.970 51 11/28/2026
0.24.1-alpha.0.907 50 11/27/2026
0.24.1-alpha.0.902 47 11/27/2026
0.24.1-alpha.0.873 51 11/27/2026
0.24.1-alpha.0.822 56 11/27/2026
0.24.1-alpha.0.782 45 11/27/2026
0.24.1-alpha.0.775 54 11/27/2026
0.24.1-alpha.0.774 53 11/27/2026
0.24.1-alpha.0.770 52 11/27/2026
0.24.1-alpha.0.769 54 11/26/2026
0.24.1-alpha.0.767 56 11/26/2026
0.24.1-alpha.0.766 58 11/26/2026
0.24.1-alpha.0.760 57 11/26/2026
0.24.1-alpha.0.759 57 11/26/2026
0.24.1-alpha.0.757 56 11/26/2026
0.24.1-alpha.0.754 67 11/26/2026
0.24.0 147 11/16/2026
Loading failed