Choosing a Go authentication library: what to check, and the real options
Most Go auth choices go wrong before the first feature comparison. Here is what to check first.
On this page
Decide who runs the user table first
Go’s standard library has no authentication package, and no single framework plays the role Devise plays for Rails. When you search for a golang authentication library, you get WebAuthn packages, OAuth helpers, full identity servers, and hosted services in one list, and they don’t compete with each other. Comparing them feature by feature wastes an afternoon.
Start with one question instead: who runs the code that owns your users and sessions? The answer puts every option into one of four shapes.
| Shape | Who runs it | You still build | Examples |
|---|---|---|---|
| Protocol library | Your binary | Users, sessions, storage, screens, and the glue | go-webauthn, x/oauth2, goth |
| Embedded framework | Your binary | Screens, and the hooks it asks for | authboss, tensile-auth |
| Self-hosted server | A second service you operate | Screens or theming, and the calls to its API | Ory Kratos, Zitadel, Keycloak, Authelia |
| Hosted service | A vendor | Your app’s side of OpenID Connect | Auth0, Clerk, WorkOS, Amazon Cognito |
Each step down that table moves work off your team and moves control and data out of your process. A single Go binary with one Postgres database leans to the top two rows. A company with ten services in three languages and a single sign-on requirement leans to the bottom two. Pick the row first, then compare within it.
What to check in any option
These nine questions decide most choices. For each one, the question to ask is what the option does for you, and what it leaves to you.
- Passkeys. Passkeys are WebAuthn credentials that resist phishing, because the browser signs only for the site that registered them (W3C WebAuthn Level 3). Check for discoverable credentials, required user verification, and sign-in from the browser’s autofill. A WebAuthn library that verifies signatures is a start. You still need ceremonies that work once, storage, and recovery.
- Sessions. OWASP asks for an idle timeout, an absolute timeout, and a fresh session ID after sign-in (OWASP Session Management Cheat Sheet). Check that revoking a session takes effect on the next request, not when a JWT expires, and that you can list and end a person’s sessions from every device.
- OAuth and OpenID Connect. There are two directions. As a client, you sign people in with Google or GitHub. As a provider, you issue tokens to other apps or command-line tools. Check which direction you need. Social login also has a classic trap: linking accounts by email address lets anyone who controls a matching address take over an account.
- Multi-factor authentication. Check which factors exist (passkeys, TOTP, SMS, recovery codes) and whether a sensitive action can ask for a fresh proof, called step-up, without signing the person out.
- Agents and API tokens. If AI agents or scripts call your API for a person, you need tokens that carry less than the person’s own access. Check for scoped, expiring tokens, a record of which person each token acts for, and revocation that reaches every token a person handed out. OAuth 2.0 Token Exchange (RFC 8693) and DPoP, which binds a token to a key (RFC 9449), are the standards to look for. The agents page shows one design.
- Storage. Check which databases it supports, whether it writes to your database or its own, and how it migrates its schema. A second database is a second thing to back up.
- Audit. When someone asks “who signed in as alice last Tuesday?”, you need an answer. Check that sign-ins, failures, revocations, and factor changes are recorded, and that the record is written in the same transaction as the change.
- Maintenance. Check the date of the latest release, the date of the latest commit, open security advisories, and whether the API is past v1. A v0 module can break its API in any release.
- Licence. MIT, BSD, and Apache-2.0 let you embed and ship the code with few conditions. AGPL-3.0 adds a condition for software you run as a network service: if you modify it, you must offer its users your modified source (GNU AGPL, section 13). That is often fine for an unmodified identity server, and a serious question for code you change or embed.
How to check a project in ten minutes
Stars and blog posts age badly. The module proxy, the vulnerability database, and the repository don’t. To check a candidate, run these four commands in a scratch module:
# The latest version and when it was published.
go list -m -json github.com/aarondl/authboss/v3@latest
# Known vulnerabilities in the code you call.
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
# How many modules come with one import.
go list -deps -f '{{with .Module}}{{.Path}}{{end}}' ./... | sort -u | wc -l
# Licence, archive state, and last push, from GitHub's API.
gh api repos/aarondl/authboss --jq '[.license.spdx_id, .archived, .pushed_at]'
The first command prints "Version": "v3.5.3" and "Time": "2025-11-25T03:16:22Z" for authboss on 23 November 2026. govulncheck reports only vulnerabilities in functions your code reaches, so it gives fewer false alarms than a list of advisories. The module count tells you what you take on: importing go-webauthn/webauthn/webauthn alone brings in 12 modules, counting itself.
Then read the last three releases’ notes. They tell you more about how a project treats security fixes and breaking changes than its feature list does.
The options in November 2026
go-webauthn and goth are protocol libraries, authboss and tensile-auth are embedded frameworks, and the rest run as services of their own. I checked every row against the project’s own repository on 23 November 2026.
| Project | Licence | Latest release | Choose it when |
|---|---|---|---|
| go-webauthn | BSD-3-Clause | v0.18.2, 19 Sep 2026 | You add passkeys to your own user system |
| goth | MIT | v1.82.0, 18 Aug 2025 | You need sign-in with many OAuth providers |
| authboss | MIT | v3.5.3, 25 Nov 2025 | You want password accounts and TOTP in your binary |
| tensile-auth | Apache-2.0 | v0.3.0 | People and their agents both call your Go app |
| Ory Kratos | Apache-2.0 | v26.2.0, 20 Mar 2026 | You want identity flows as an API, with your own screens |
| Zitadel | AGPL-3.0 | v4.20.5, 18 Nov 2026 | You need multi-tenant B2B identity, SAML, and SCIM |
| Keycloak | Apache-2.0 | 26.8.2, 5 Nov 2026 | You need SAML, LDAP, and enterprise single sign-on |
| Authelia | Apache-2.0 | v4.39.28, 17 Sep 2026 | You protect existing apps behind a reverse proxy |
| Hosted services | Proprietary | Not applicable | You’d rather pay than operate identity |
go-webauthn/webauthn is a WebAuthn relying-party library, and tensile-auth’s passkey package builds on it. Its README states its scope: it handles Web Authentication, and your user model must store and return its webauthn.Credential records. It is still v0, and the README warns of breaking changes. Choose it when you already have users and sessions and want passkeys added correctly.
markbates/goth lists 64 OAuth providers in its README, and its gothic package keeps OAuth state in a gorilla/sessions cookie store by default. Its latest release is from August 2025, and its latest commit from February 2026. Choose it for broad social login. If you only need Google and GitHub, golang.org/x/oauth2 and coreos/go-oidc (v3.21.0, 1 September 2026) do the same job with fewer modules, and you control where state lives.
authboss is a modular authentication framework for web apps. Its modules cover password sign-in, registration, email confirmation, password recovery, account locking, remember-me, OAuth 2 sign-in, TOTP and SMS second factors, and recovery codes. Its module list has no WebAuthn module. Choose it for a password-based app that needs the usual account flows in one binary.
Ory Kratos runs login, registration, recovery, verification, and MFA as HTTP APIs, and you bring the screens. It supports passkeys with a dedicated strategy (Ory docs). Its public repository was last updated on 29 July 2026, with commits synced from Ory’s internal repository. Pair it with Ory Hydra when you also need to be an OAuth provider.
Zitadel describes itself as an identity and access management platform with SSO, MFA, passkeys, OIDC, SAML, SCIM, and multi-tenancy, and it needs PostgreSQL 14 or later. The server is AGPL-3.0. Its Go OpenID Connect library, zitadel/oidc, is Apache-2.0 and released v3.53.0 on 23 November 2026, so you can embed the protocol code without the server’s licence.
Keycloak covers enterprise single sign-on: OpenID Connect, SAML, user federation such as LDAP, and a passkeys section in its admin guide (Keycloak docs). It is a Java service and a CNCF project. Choose it when the requirement list says “SAML” and “Active Directory”.
Authelia isn’t a library for your app’s accounts. It is a sign-in portal that works with nginx, Traefik, Caddy, and other reverse proxies, adds passkeys, security keys, and TOTP in front of apps that have no sign-in of their own, and is OpenID Certified for several provider profiles. Choose it for internal tools and home labs.
Hosted services such as Auth0, Clerk, WorkOS, and Amazon Cognito run the user database and the sign-in screens. Your Go code checks their tokens with an OpenID Connect library such as coreos/go-oidc. You trade cost per user and data residency for not running identity at all.
Two more servers are worth a look if they fit: Hanko, a Go server that can run passkey-only (backend AGPL-3.0, frontend elements MIT; backend v3.2.0, 20 November 2026), and Supabase Auth, the Go service behind Supabase sign-in (MIT; v2.198.0, 16 November 2026).
Where tensile-auth fits
tensile-auth is an embedded framework for one case: a Go app where people sign in with passkeys and then hand work to AI agents. It is at v0.3.0.
What it does, from its README and changelog:
- Passkeys first, no passwords. Passkey sign-up, sign-in, and step-up on
go-webauthn/webauthn, with TOTP and recovery codes as extra factors. - Agent sessions. A person delegates a session to an agent with narrower scopes and an earlier expiry, and revoking the person’s session revokes every session delegated from it.
- Tokens for machines. Personal access tokens, DPoP-bound agent tokens, and an embedded OAuth 2 and OpenID Connect provider with the device flow and token exchange, built on
zitadel/oidc. - Social login without email linking. Google, GitHub, and other OpenID Connect providers, keyed by the provider’s subject, never by email address.
- Audit. A hash-chained audit log that
VerifyAuditchecks for edits and deletions. The security page has the details. - Storage. In-memory, SQLite, and PostgreSQL stores, each passing one conformance suite.
- Sessions bound to the device. Opt-in Device Bound Session Credentials.
What it doesn’t do: passwords, email codes or magic links (it sends no email), SAML, permissions beyond opaque scopes, or a hosted service. It has no external security audit; its OpenID Connect results come from running the OpenID Foundation’s conformance suite in its own CI, not from paid certification. It is pre-1.0.
This program runs against the library’s main branch. It signs alice in, gives an agent a read-only session, and shows that signing alice out ends the agent’s session too:
package main
import (
"context"
"fmt"
"log"
"tensile.tools/auth"
"tensile.tools/auth/memstore"
)
func main() {
ctx := context.Background()
svc, err := auth.New(memstore.New())
if err != nil {
log.Fatal(err)
}
// After your app has signed alice in, start her session.
_, alice, err := svc.StartSession(ctx, "alice", auth.StartOptions{
Scopes: []string{"repo:read", "repo:write"},
})
if err != nil {
log.Fatal(err)
}
// alice registers an agent and gives it a narrower session.
agent, err := svc.CreateAgent(ctx, alice, auth.AgentSpec{Name: "Claude Code", Scopes: []string{"repo:read"}})
if err != nil {
log.Fatal(err)
}
tok, _, err := svc.Delegate(ctx, alice, auth.DelegateSpec{Agent: agent.ID, Scopes: []string{"repo:read"}})
if err != nil {
log.Fatal(err)
}
p, err := svc.Authenticate(ctx, tok.Reveal())
if err != nil {
log.Fatal(err)
}
fmt.Println("agent acts for:", p.User, "agent:", p.IsAgent())
// Signing alice out ends her agent's session too.
if err := svc.Revoke(ctx, alice.Session); err != nil {
log.Fatal(err)
}
_, err = svc.Authenticate(ctx, tok.Reveal())
fmt.Println("agent token after revoke:", err)
}
It prints:
agent acts for: alice agent: true
agent token after revoke: auth: unauthenticated
Whatever you choose, write this test against it. If your library can’t express “this token acts for alice and dies with her session”, you will build that part yourself.
When to choose something else
- You need passwords. Use authboss, Kratos, or a hosted service.
- You need SAML or LDAP. Use Keycloak or Zitadel.
- You run many services in several languages. Use a self-hosted server or a hosted service, so every service trusts one issuer.
- You protect apps you didn’t write. Use Authelia.
- You already have users and only need passkeys. Use
go-webauthn/webauthndirectly.
FAQ
What is the best golang authentication library?
There isn’t one best library, because the options solve different problems. Decide whether your binary, a second service, or a vendor owns your users, then compare the options in that group with the nine checks above.
Should I write my own authentication in Go?
Write the glue, not the cryptography. Use maintained libraries for WebAuthn, OAuth, and token signing, and test your own session and revocation rules as carefully as any other security code.
Are JWTs good session tokens?
They are a poor default for browser sessions, because you can’t revoke a JWT before it expires without a lookup, and then an opaque token is simpler. JWTs fit tokens that other services verify without calling you, such as OpenID Connect ID tokens.
Is AGPL a problem for an identity server?
Running an unmodified AGPL server usually asks little of you. Modifying it, or linking its code into your own service, triggers the duty to offer your source to its network users. Ask your legal team before you embed AGPL code.
Which option supports passkeys?
go-webauthn/webauthn, Kratos, Zitadel, Keycloak, Authelia, Hanko, and tensile-auth all document passkey or WebAuthn support. authboss lists no WebAuthn module.
Key takeaways
- Choose the shape first: protocol library, embedded framework, self-hosted server, or hosted service.
- Check passkeys, sessions, OAuth direction, MFA, agent tokens, storage, audit, maintenance, and licence.
- Verify maintenance with
go list -m -json,govulncheck, and the repository, not with stars. - Read licences: AGPL-3.0 servers ask more of you than Apache-2.0, MIT, or BSD code.
- tensile-auth fits Go apps where people and their agents both act; for passwords, SAML, or many services, another option is the better choice.
Try it
Give your coding agent this line to add tensile-auth to your Go app:
Add sign-in with tensile-auth. Read https://auth.tensile.tools/llms.txt and follow it.