go-app

command
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 16 Imported by: 0

README

Example Go application

The example shows a complete Auth-All integration: SQLite, email and password authentication with verification, GitHub and Google sign-in, Magic Link, passkeys, an in-memory rate limit for development, and structured events.

Run

go run ./cmd/auth-all migrate --driver sqlite --dsn "file:example.db"

export APP_URL=http://localhost:8080
export GITHUB_CLIENT_ID=...
export GITHUB_CLIENT_SECRET=...
export GOOGLE_CLIENT_ID=...
export GOOGLE_CLIENT_SECRET=...

go run ./examples/go-app

The example prints every email it must deliver, including the verification link and the sign-in link. A production application sends the message through its own provider.

Try it

curl -X POST http://localhost:8080/api/auth/sign-up/email \
  -H 'Content-Type: application/json' \
  -d '{"email":"user@example.com","password":"a long password"}'

Open the verification link from the log. The example serves the page at /verify-email and consumes the token with auth.VerifyEmailToken:

curl "http://localhost:8080/verify-email?token=<the token from the log>"

Then sign in and call /me:

curl -i -c cookies.txt -X POST http://localhost:8080/api/auth/sign-in/email \
  -H 'Content-Type: application/json' \
  -d '{"email":"user@example.com","password":"a long password"}'

curl -b cookies.txt http://localhost:8080/me

Passkeys

Open http://localhost:8080/passkeys in a browser. Use localhost, not 127.0.0.1, because a passkey binds to a domain. Sign in with the password of a verified account, register a passkey, sign out, and sign in with the passkey.

Documentation

Overview

Command example-app shows a complete Auth-All integration in a small Go application. It uses SQLite, email and password authentication, GitHub and Google sign-in, the Magic Link plugin, and the passkeys plugin.

Run the migration before the first start:

go run ./cmd/auth-all migrate --driver sqlite --dsn file:example.db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL