Getting Started
Install Gorta and wire up auth in a Go HTTP server.
Gorta is a minimal, adapter-based authentication library for Go. You bring the database; Gorta handles sessions, cookies, and plugin HTTP routes.
Install
go get github.com/etornam45/gortaPrerequisites
- Go 1.22+ (stdlib
http.ServeMuxroute patterns) - A SQL database (or your own
core.Storageimplementation) - A signing secret of at least 32 characters
Quick start
storage := sqladapter.New(db)
emailPlugin, err := emailpassword.New(storage, storage, mailer, emailpassword.Config{
VerifyEmail: true,
})
auth, err := gorta.New(storage, gorta.Config{
Secret: os.Getenv("SECRET"),
BaseURL: os.Getenv("BASE_URL"),
}, gorta.WithPlugin(emailPlugin))
mux := http.NewServeMux()
mux.Handle("/auth/", http.StripPrefix("/auth", auth.Handler()))
mux.Handle("/dashboard", auth.RequireAuth()(http.HandlerFunc(dashboard)))
http.ListenAndServe(":8080", auth.Middleware()(mux))Auth routes live under /auth (for example POST /auth/sign-in). Session middleware loads the cookie on every request; RequireAuth guards private handlers.
Environment variables
| Variable | Description |
|---|---|
SECRET | Session signing secret (32+ characters) |
BASE_URL | Public URL of your API (OAuth redirects, email links) |
SESSION_DURATION | Optional session lifetime (e.g. 168h) |
COOKIE_SECURE | Set true in production (HTTPS only) |
COOKIE_DOMAIN | Optional cookie domain |
COOKIE_NAME | Optional cookie name (default gorta_session) |
Example project
A full working server with email/password, magic links, and OAuth is in the repository:
Next steps
Plugin guides, storage adapters, and HTTP API reference are coming soon. For now, explore the repository README and plugin packages under plugins/.