Under active development. The API may change.
Authentication for Go, built from plugins
Behemoth adds sign-up, sign-in, and session management to your Go application, on the database and HTTP framework you already use.
$ go get github.com/go-behemoth/behemoth plugin := emailpassword.New(emailpassword.Options{})
app, err := engine.Prepare(
[]core.Plugin{plugin},
engine.PrepareConfig{},
)
if err != nil {
log.Fatal(err)
}
db := postgres.NewPostgresAdapter(sqlDB, app.Resolver)
router := gin.New()
ac, err := engine.Boot(
ctx,
app,
db,
engine.BootConfig{
// Crypto and Session options go here.
HTTP: ginadapter.New(router),
},
)
if err != nil {
log.Fatal(err)
}Authentication, assembled from parts
Pick the plugins and the database. Behemoth sets up the tables, routes, sessions, hooks, and telemetry around them.
Plugins
Each plugin declares its own routes, tables, hooks, and rate limits. Choose email and password, magic links, email verification, usernames, or phone numbers.
Migrations
Behemoth builds a migration from the tables your plugins and schema declare, and writes it to a folder for you to review.
Hooks
Run your code before or after a user is written, or around a whole flow such as sign-up. A handler can change data, stop an operation, or react afterward.
Sessions and tokens
Store sessions in your database or a key-value store, and deliver them as a cookie or a header.
Telemetry
Collect logs, audit events, metrics, and traces, with an OpenTelemetry adapter.
Security defaults
Behemoth includes rate limiting and Argon2id password hashing, so a new project starts with both in place.
Works with your stack
Adapters are separate modules, so you download only what you use.
Routers
- net/http
- Gin
- Echo
- chi
- Fiber
Databases and stores
- PostgreSQL
- MySQL
- SQLite
- SQL Server
- MongoDB
- Bun
- GORM
- Redis
Join the community
Ask questions, report problems, and follow the project's development.
Add authentication to your Go application
The quick start takes you from an empty project to working sign-up and sign-in routes.
Start the quick start