KScript docs
EN

Sign-in: KScript.Auth

Introduction

KScript.Auth gives a kscript serve app accounts that people sign in to. It keeps the users, hashes their passwords with argon2id, and keeps their sessions in a cookie with safe defaults. It also checks a CSRF token on every form, limits failed sign-ins, and handles password resets and API tokens. The email and password types check what people type, so the rules live in one place: your kscript.json.

Quick start

The quickest start is kscript make auth, which writes the pages, routes and controller for you:

CommandWhat it does
kscript make authSign up, sign in, sign out, forgot password and an account page.
kscript make auth --apiThe same, plus POST /api/tokens and GET /api/me for API tokens.
kscript make auth --passkeysAccounts that sign in with a passkey instead of a password.

Then run kscript serve, open /register to make an account, and open /account to see it. The rest of this guide explains what those files do, so you may change them or write your own.

Edit this page on GitHub