GOTTH+
GitHub

Building

Sign-in

The four sign-in options, what they set up, and the settings each one needs.

Choosing a sign-in option

Pick one with --auth when you create the project. Every option except none adds the same server-side sessions, and only the code for the methods you choose is written into the project.

--authWhere users liveGood for
none (default)Nowhere: no users and no sessions. Every route is public.Learning, prototypes and public sites.
supabaseSupabase Auth: email and password, plus any provider you enable in Supabase. The database is Supabase's Postgres, so --db is set to postgres.Production apps that want accounts, MFA and recovery handled by a hosted service.
oidcA hosted OpenID Connect provider: WorkOS, Logto, Kinde, Auth0, Zitadel, Keycloak or any other with discovery.Production apps, single sign-on, and teams that already have a provider.
builtinThe app's own database: email and password, Google, GitHub and Apple. Experimental and only for advanced use.Teams ready to own password storage, email delivery and provider sign-in themselves.
go run github.com/owenwexler/create-gotth-plus-app@latest my-app --auth=supabase
go run github.com/owenwexler/create-gotth-plus-app@latest my-app --auth=oidc --oidc-preset=workos
go run github.com/owenwexler/create-gotth-plus-app@latest my-app --auth=builtin --auth-methods=password,github

What every option sets up

  • Server-side sessions (alexedwards/scs) in a sessions table, so they can be revoked. The cookie is __Host-session in production: HttpOnly, Secure and SameSite=Lax, lasting 7 days at most and 24 hours idle.
  • Every sign-in issues a new session token and a new CSRF token (csrf.Rotate), so a token planted or seen earlier stops working.
  • auth.CurrentUser(ctx) is the signed-in user. Wrap routes that need one in auth.RequireUser, and authorise every object by fetching it with both its id and its owner's id.
  • Sign out, and Sign out everywhere, which raises User.SessionVersion and so ends every session the user has.
  • ?next= after sign-in only accepts paths on the same site (auth.SafeNext), so it can't send anyone elsewhere.
  • Routes: GET /login, GET /account, POST /logout and POST /logout-everywhere, plus the routes of the chosen methods.
  • BaseURL, the app's public address. Emailed links and the providers' redirect URLs are built from it, never from the request's Host header, which the client controls. It must be https in production, and defaults to http://localhost:7331 in development.

In development, a method whose keys are empty is left off the sign-in page, so the project runs before you register anything. In production, the app refuses to start without them.

Supabase Auth

SettingWhat it is
SupabaseURLThe project URL, from Project Settings > API.
SupabasePublishableKeyThe publishable (anon) key. Never the secret or service_role key: it bypasses Supabase's row-level security.
SupabaseProvidersOptional. The providers enabled in Supabase that get a Continue with button, such as google,github. Empty means email and password only.
DatabaseURLThe project's Postgres, from Connect > Session pooler, with sslmode=require.

In Supabase, under Authentication > URL Configuration, set the Site URL to BaseURL and allow <BaseURL>/auth/supabase/callback and <BaseURL>/reset-password as redirect URLs.

  • Users and passwords live in Supabase. The app keeps its own users row, linked by Supabase's user ID, and its own session. Supabase's tokens are checked with Supabase, used once and never stored.
  • Every flow, including provider sign-in and the confirmation and reset links, uses PKCE. The verifier stays in this browser's __Host-supabase-flow cookie, so a reset link only works in the browser that asked for it.
  • Passwords are 15 to 72 characters. Set Supabase's own minimum no higher.
  • A user banned or deleted in Supabase stays signed in to the app until their session ends, or until you raise their SessionVersion.

OpenID Connect

--oidc-preset fills .env.example with the right hints for a known provider. The app reads everything else from the issuer's discovery document.

--oidc-presetCreate the client asIssuer looks like
workosAn OAuth application under Connecthttps://<your-subdomain>.authkit.app
logtoA Traditional web applicationhttps://<tenant-id>.logto.app/oidc
kindeA back-end web applicationhttps://<your-business>.kinde.com
auth0A Regular Web Applicationhttps://<tenant>.<region>.auth0.com/
zitadelA web application with code flowhttps://<instance>.zitadel.cloud
keycloakA confidential OpenID Connect client in the realmhttps://<host>/realms/<realm>
other (default)Any provider with /.well-known/openid-configurationhttps://issuer.example.com

Set OIDCIssuerURL, OIDCClientID and OIDCClientSecret, and optionally OIDCLabel, the button's text after Continue with. At the provider, allow <BaseURL>/auth/oidc/callback as the redirect URI and <BaseURL>/ as the post-logout redirect URI.

  • Sign-in checks a random state, uses PKCE, and checks the ID token's signature, audience, expiry, nonce and issuer, which must be exactly OIDCIssuerURL.
  • The provider must send email_verified. Accounts are only made for verified emails, and users are matched by the provider's subject, never by email alone.
  • Signing out also ends the session at the provider when its discovery document has an end_session_endpoint. Some providers, such as WorkOS, don't have one.

Built-in sign-in

Built-in sign-in follows current guidance (OWASP, NIST SP 800-63B-4) and is covered by tests, but it hasn't been independently audited, and keeping passwords, sessions and provider sign-in safe becomes your job. A hosted service also takes care of MFA, breach protection and account recovery. Choose the methods with --auth-methods: any of password, google, github and apple.

MethodSettingsNotes
passwordSMTPHost, SMTPPort (587), SMTPUsername, SMTPPassword, MailFromConfirmation and reset emails. In development, with SMTPHost empty, emails and their links go to the server log.
googleGoogleClientID, GoogleClientSecretAn OAuth client in the Google Cloud console.
githubGitHubClientID, GitHubClientSecretAn OAuth app in GitHub's developer settings.
appleAppleClientID, AppleTeamID, AppleKeyID, ApplePrivateKeyFileA Services ID and a .p8 key. Apple only allows https redirect URLs, so trying it locally needs an https tunnel.

Each provider's redirect URL is <BaseURL>/auth/<provider>/callback.

  • Passwords are hashed with argon2id, 15 to 256 characters, with no rules about kinds of characters. An unknown email costs the same time as a wrong password, and sign-in, sign-up and reset answer the same whether or not an account exists.
  • Emailed links carry single-use, expiring tokens stored only as SHA-256. They open a page that changes nothing until its button posts.
  • Sign-in, sign-up and reset emails are rate-limited per email address as well as per client address.
  • Provider sign-in checks a random state, uses PKCE where the provider supports it (Apple doesn't), and checks the ID token's nonce for Google and Apple. An email links to an existing account only when the provider has verified it and the account's email is confirmed too, so nobody can take over an account by signing in elsewhere with someone else's address.
  • Apple comes back with a cross-site POST, so POST /auth/apple/callback alone skips the CSRF and cross-origin checks. Its state and nonce protect it. Keep the .p8 file out of the repository and the image.
  • make seed also creates dev@example.com, confirmed, with the password in SeedUserPassword, which the generator fills with a random value in .env.

Known limits

  • There is no second factor (TOTP or passkeys) yet.
  • Authorisation is yours: auth.RequireUser only checks that someone is signed in.
  • The CSRF token is replaced at sign-in and sign-out but not bound to the session.
  • Password sign-in, built-in or Supabase, needs JavaScript: the forms rely on htmx sending the CSRF header.

Was this page helpful?

Be the first to answer.