Passport for Go

github.com/malcolmston/passport

Simple, unobtrusive authentication.

 GitHubports jaredhanson/passport

A strategy-based auth middleware for net/http. 100+ strategies — local, basic, bearer, JWT, OAuth2 with 60+ providers, WebAuthn passkeys, and OpenID Connect with RS256/JWKS — plus session serialize/deserialize.

Install

shell
$ go get github.com/malcolmston/passport

Quick start

main.go
p := passport.New()

p.Use(local.New(func(user, pw string) (any, error) {
    if user == "alice" && pw == "password123" {
        return User{ID: "1", Name: "Alice"}, nil
    }
    return nil, local.ErrInvalidCredentials
}))

Features

  • Strategy interface with Success / Fail / Redirect / Error / Pass
  • Local, Basic, Bearer, API-key, HMAC, TOTP/HOTP, magic-link, client-cert …
  • OAuth2 base + 60+ providers: Google, GitHub, Facebook, Slack, Discord, Apple …
  • OpenID Connect id_tokens verified via RS256/ES256 JWKS (Google, Auth0, Okta, Azure)
  • WebAuthn / passkeys (CBOR + COSE, ES256/RS256 assertions)
  • Session SerializeUser / DeserializeUser, pluggable Store
  • RequireLogin gate, custom callbacks, multi-strategy, passReq
Passport