go-auth

Routes

Every HTTP route go-auth mounts, grouped by area, with path params, query params, and request body fields.

Routes

This page covers every route Auth.Mount(mux) registers. Paths in the tables use {name} for a path parameter read via r.PathValue("name"). "Auth" is the minimum session/role required — see Architecture for the full middleware chain each route runs through, and Error Handling for what each one returns on failure.

A few routes are conditionally mounted and simply don't exist on the mux otherwise:

  • Everything under Invites requires RegistrationConfig.EnableInvite: true.
  • Everything under OAuth requires RegistrationConfig.EnableOAuth: true and at least one WithProvider call.
  • Everything under Organizations requires WithOrganizations(OrganizationConfig{Enable: true}).
  • POST /auth/register / POST /auth/signup require RegistrationConfig.EnableEmailPassword: true.

Whenever SecurityConfig.AllowedOrigins is non-empty, Mount also registers an OPTIONS twin for every distinct path (deduplicated across methods sharing one), short-circuited to 204 by the CORS middleware before reaching any handler — these aren't listed separately below.

Authentication

Method & PathAuthBodyDescription
POST /auth/register, POST /auth/signupPublic`{email, password, name}`Register with email/password. Returns a session unless verification is required.
POST /auth/login, POST /auth/signinPublic`{email, password}`Log in. May return requiresVerification: true instead of a session.
POST /auth/admin/loginPublic`{email, password}`Same as login, but only succeeds for role: admin users.
POST /auth/logout, POST /auth/signoutPublic (session cookie optional)noneRevokes the current session if the cookie is present; clears cookies either way.
GET /auth/meAuthnoneReturns the authenticated user plus hasPassword.
GET /auth/checkPublic (session cookie optional)noneSoft check — always 200, returns {"user": null} instead of erroring when there's no valid session.
GET /auth/csrf-tokenPublicnoneNo-op handler (204) — the CSRF cookie/header is actually issued by the CSRF middleware wrapping this route. Call it to prime the cookie before your first mutating request.
PUT /auth/nameAuth`{name}`Updates the authenticated user's display name.

Sessions

Method & PathAuthParamsDescription
GET /auth/sessionsAuthQuery: offset (int, default 0), limit (int, default 20, max 100)Paginated list of your own sessions, plus current_session_id.
GET /auth/sessions/allAuthnoneAll of your sessions, unpaginated, plus current_session_id.
DELETE /auth/sessions/{id}AuthPath: idRevokes one of your own sessions. 404 session_not_found if it doesn't exist or isn't yours — the two cases are indistinguishable on purpose.
POST /auth/sessions/revokeAuthBody: `{session_ids: []string}`Bulk-revokes up to 100 of your own session IDs at once; unrecognized/foreign IDs are silently skipped. Returns revoked count.
DELETE /auth/sessionsAuthnoneRevokes all your sessions except the one making the request (or all of them if the current one can't be resolved).
POST /auth/refreshPublic (refresh cookie required)Cookie: refresh token cookieRotates the session using the refresh cookie. Sets new session+refresh cookies on success; clears both on failure.

Password

Method & PathAuthBodyDescription
POST /auth/forgot-passwordPublic`{email}`Always returns a generic success message, whether or not the account exists.
POST /auth/reset-passwordPublic`{code, newPassword}`Completes a password reset using the emailed code.
PUT /auth/password, POST /auth/change-passwordAuth`{oldPassword, newPassword}`Changes the authenticated user's password; revokes every other session.
POST /auth/set-password/requestAuthnoneSends a set-password email link — for OAuth-only accounts with no password yet.
POST /auth/set-password/confirmPublic`{userId, code, newPassword}`Confirms a set-password request. Unauthenticated by design — userId comes from the body, not a session.

Account

Method & PathAuthBodyDescription
DELETE /auth/accountAuth`{password}`Deletes the account immediately after password confirmation.
POST /auth/account/delete/requestAuthnoneEmails a deletion confirmation code. For OAuth-only accounts (no password) instead of the immediate-delete route above.
POST /auth/account/delete/confirmAuth`{code}`Confirms deletion with the emailed code. The user is always the authenticated session, never taken from the body.

Email verification

Method & PathAuthBodyDescription
POST /auth/verify-emailPublic`{code}`Verifies the email and immediately creates a session for the now-verified user.
POST /auth/resend-verificationAuthnoneResends the verification email to the authenticated (unverified) user.
POST /auth/verify-email/resendPublic`{email}`Unauthenticated resend by email address. Always returns a generic success message — no enumeration.

Invites (self-service signup) — requires EnableInvite

Method & PathAuthParamsDescription
GET /auth/invite/infoPublicQuery: token (required)Looks up an invite by token — used to pre-fill a registration form. 400 missing_token if omitted.
POST /auth/invite/registerPublicBody: `{code, name, password, confirmPassword}`Completes registration from an invite code, creating the account and a session in one step.

OAuth — requires EnableOAuth and at least one registered provider

Method & PathAuthParamsDescription
GET /auth/oauth/{provider}PublicPath: providerStarts the OAuth flow. Returns `{url}` to redirect the browser to.
GET /auth/oauth/{provider}/callback, POST /auth/oauth/{provider}/callbackPublicPath: provider; form values code, state (from query on GET, parsed form body on POST)Completes the code exchange. On success, sets cookies and redirects to {BaseURL}/auth/callback; on error, redirects to {BaseURL}/auth/callback?error={code}&provider={provider} — see Error Handling.
POST /auth/oauth/{provider}/linkAuthPath: providerLinks a provider to the already-authenticated account. Returns `{url}`.
POST /auth/oauth/{provider}/unlinkAuthPath: providerUnlinks a provider. Blocked if it would leave the account with no way to log in.
GET /auth/oauth/providersAuthnoneLists connected providers — provider, email, name, avatar_url, created_at only. Access/refresh tokens are never returned.

Organizations — requires WithOrganizations(Enable: true)

Method & PathAuthParamsDescription
POST /auth/orgsAuthBody: `{name, slug}`Creates an org owned by the caller.
GET /auth/orgsAuthnoneLists the orgs the caller belongs to.
GET /auth/orgs/{orgID}Org memberPath: orgIDFetches one org.
PUT /auth/orgs/{orgID}Org adminPath: orgID; body: `{name?, slug?}` (both pointers — omit a field to leave it unchanged)Partial update of org name/slug.
DELETE /auth/orgs/{orgID}Org ownerPath: orgIDDeletes the org.
GET /auth/orgs/{orgID}/membersOrg memberPath: orgID; query: offset, limit (default 20, max 100, same clamping as other list endpoints — applied in OrgService.ListMembers, not the handler)Lists org members.
DELETE /auth/orgs/{orgID}/members/{userID}Org adminPath: orgID, userIDRemoves a member.
PATCH /auth/orgs/{orgID}/members/{userID}/roleOrg adminPath: orgID, userID; body: `{role}`Changes a member's role.
POST /auth/orgs/{orgID}/leaveOrg memberPath: orgIDThe caller leaves the org.
PUT /auth/orgs/activeAuthBody: `{orgId}`Sets the caller's active org for the current session. No {orgID} path segment — membership is checked inside the service, not by middleware.
DELETE /auth/orgs/activeAuthnoneClears the active-org setting for the current session.
POST /auth/orgs/{orgID}/invitesOrg adminPath: orgID; body: `{email, role}`Creates an invite to join the org.
POST /auth/orgs/invites/acceptAuthBody: `{code}`Accepts an org invite by code. No path segment — the invite is resolved from the code.
GET /auth/orgs/{orgID}/invitesOrg adminPath: orgIDLists an org's invites.
POST /auth/orgs/{orgID}/invites/{inviteID}/resendOrg adminPath: orgID, inviteID (orgID is only used for the authorization check, not read again inside the handler)Resends an org invite email.
DELETE /auth/orgs/{orgID}/invites/{inviteID}Org adminPath: orgID, inviteID (same note as above)Deletes an org invite.

Admin — users

Method & PathAuthParamsDescription
GET /admin/usersAdminQuery: offset, limit (default 20, max 100); email, search (optional filters); role (admin or user only — any other value is ignored, not applied); orderBy (created_at | updated_at, default created_at); orderDirection (asc | desc, default desc)Paginated, filterable, sortable user listing.
GET /admin/users/{id}AdminPath: idFull detail for one user.
POST /admin/usersAdminBody: `{email, password, name, role}`Admin-creates a user with a specified role.
PATCH /admin/users/{id}/roleAdminPath: id; body: `{role}`Sets a user's role. Blocked if it would demote the last admin.
PATCH /admin/users/{id}/banAdminPath: idBans a user. Blocked for the last admin.
PATCH /admin/users/{id}/unbanAdminPath: idUnbans a user.
DELETE /admin/users/{id}AdminPath: idDeletes a user. Blocked for the last admin.
GET /admin/users/{id}/sessionsAdminPath: id; query: offset, limit (default 20, max 100)Paginated sessions for a specific user.
DELETE /admin/users/{id}/sessions/{sessionId}AdminPath: id, sessionIdRevokes one specific session belonging to a specific user.
DELETE /admin/users/{id}/sessionsAdminPath: idRevokes all of a user's sessions.

Admin — audit logs

Method & PathAuthParamsDescription
GET /admin/audit-logsAdminQuery (all optional): offset, limit (default 50, max 200); event_type, actor_id, target_user_id, session_id, org_id, search; from, to (RFC3339 timestamps — silently ignored if unparsable); success (true | false)Filtered, paginated audit events. 404 audit_not_configured if audit logging isn't enabled.
GET /admin/users/{id}/audit-logsAdminPath: id; same query params as aboveSame as above, pre-filtered to that user.

Admin — invites (EnableInvite required)

Method & PathAuthParamsDescription
POST /admin/invitesAdminBody: `{email}`Creates an invite. The inviting admin is taken from the session, not the body.
GET /admin/invitesAdminQuery: offset, limit (default 20, max 100); search, status (optional)Lists invites.
DELETE /admin/invites/{id}AdminPath: idRevokes (soft-cancels) an invite.
POST /admin/invites/{id}/resendAdminPath: idResends the invite email.
DELETE /admin/invites/{id}/hardAdminPath: idPermanently deletes the invite record.

On this page