Add AUTH_DISABLED opt-out for sharedauth's new pending mode
Docker / Docker Build & Push (push) Successful in 5m39s
Lint / Lint (push) Successful in 51s
Tests / Go backend (push) Successful in 1m12s
Tests / Dashboard checks (push) Successful in 1m11s

sharedauth.NewWithStore now treats an empty AUTHGUARD_URL as "pending"
(still gated, failing closed) rather than permanently disabled, so a
ProjectConfigurator-registered CollabTable no longer needs
AUTHGUARD_URL set at all. Add AUTH_DISABLED (default false) to opt
into the old fully-open behavior explicitly via sharedauth.Disabled(),
and update both READMEs/.env.example to document the three resulting
states.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Gabriel20xxandClaude Sonnet 5 committed 2026-09-14 14:12:34 +02:00
1 parent a018f3da4c
commit f723afa369
7 files changed
+84 -38

No files matched your search

+16 -6
View File
@@ -11,12 +11,20 @@ COOKIE_SECURE=false
# Authentication (AuthGuard)
#################################################################
# Base URL of the AuthGuard centralized identity service this app authenticates
# through instead of a local user table.
# through instead of a local user table. AuthGuard integration has three states:
# - AUTHGUARD_URL set: used immediately.
# - AUTHGUARD_URL unset, AUTH_DISABLED unset/false (the default): "pending"
# -- auth stays fully enabled/gated, waiting for ProjectConfigurator to
# push a live URL (see below), and fails closed on auth calls until one
# arrives.
# - AUTH_DISABLED=true: authentication is fully off (no login screen,
# everything open).
# AUTHGUARD_URL=https://auth.example.com
# Leaving AUTHGUARD_URL unset does NOT fall back to any local account store --
# it disables authentication entirely (no login screen, everything open).
# Only run without it for local development or a deployment you are certain
# does not need access control.
# AUTH_DISABLED=true
# Only set AUTH_DISABLED=true for local development or a deployment you are
# certain does not need access control. Leaving AUTHGUARD_URL unset does NOT
# do this -- it just leaves the service "pending" until ProjectConfigurator's
# push arrives.
# Base URL of a CarrierNode instance, for the generic per-project mount API
# (not used by any feature here yet).
@@ -29,7 +37,9 @@ COOKIE_SECURE=false
# automatically (PUT /api/core-services/internal) and keeps them current --
# see Core/ProjectConfigurator/README.md's "Pushing core service info to
# other projects". That push is itself authenticated with this secret, so it
# still needs to be set even though AUTHGUARD_URL/CARRIERNODE_URL don't.
# still needs to be set even though AUTHGUARD_URL/CARRIERNODE_URL don't. A
# push never overrides AUTH_DISABLED=true; it only ever retargets an
# already-enabled AuthGuard connection.
# INTERNAL_SERVICE_SECRET=
#################################################################
+11 -6
View File
@@ -79,8 +79,10 @@ notification events.
Browser authentication proxies to AuthGuard (`AUTHGUARD_URL`), which sets and reads its own
`auth_session` HTTP-only cookie; CollabTable itself mints no session token. Any number of
accounts can exist, with `user`/`admin`/`superadmin` roles managed via `/api/auth/users`.
`AUTHGUARD_URL` is optional: leaving it unset disables authentication entirely (no login
screen, nothing gated) rather than falling back to any local account store -- only use that for
AuthGuard integration has three states: `AUTHGUARD_URL` set (used immediately); unset with
`AUTH_DISABLED` unset/false (the default -- "pending": auth stays fully enabled/gated, waiting
for ProjectConfigurator's push, failing closed on auth calls until then); or `AUTH_DISABLED=true`
(authentication fully off -- no login screen, nothing gated). Only set `AUTH_DISABLED=true` for
local development or a deployment you are certain does not need access control. API tokens are
unrelated to AuthGuard (see below), hashed at rest, and shown only when generated.
@@ -112,10 +114,13 @@ unrelated to AuthGuard (see below), hashed at rest, and shown only when generate
- `APP_VERSION` — optional version displayed in the dashboard, default `dev`
- `COOKIE_SECURE` — set to `true` when served over HTTPS
- `DATABASE_URL` — PostgreSQL connection string, required
- `AUTHGUARD_URL` — base URL of the AuthGuard identity service CollabTable authenticates
against, default unset (auth disabled). Leaving it unset does not fall back to any local
account store -- it disables authentication entirely, treating every request as
authenticated with nothing gated.
- `AUTHGUARD_URL` — optional bootstrap/override base URL of the AuthGuard identity service
CollabTable authenticates against, default unset (pending). Leaving it unset does not disable
authentication -- it leaves the service "pending" until ProjectConfigurator pushes a URL,
failing closed on auth calls until then. Use `AUTH_DISABLED` to actually turn auth off.
- `AUTH_DISABLED` — set `true` to disable authentication entirely (no login screen, nothing
gated, every request treated as authenticated), default `false`. For local development or a
standalone deployment with no AuthGuard integration at all.
- `DB_INIT_RETRY_INTERVAL_MS` — startup retry delay, default `5000`
- `DB_INIT_RETRY_MAX_ATTEMPTS` — maximum startup attempts, `0` retries forever
- `SYNC_MAX_FUTURE_SKEW_MS` — allowed client timestamp skew, default `0`
+16 -7
View File
@@ -102,13 +102,22 @@ func (s collabTableAuthStore) UnclaimSetup(ctx context.Context) error {
}
// newAuthService builds CollabTable's sharedauth.Service. authGuardURL is
// AUTHGUARD_URL; empty means auth-disabled mode (see the package doc comment
// above and sharedauth's own "Auth-disabled mode" section). "collabtable" is
// CollabTable's projectKey, letting an AuthGuard administrator restrict which
// accounts may log into CollabTable specifically -- handled entirely
// server-side by AuthGuard once passed here.
func newAuthService(database *DB, authGuardURL string, secureCookies bool) *sharedauth.Service {
return sharedauth.NewWithStore(collabTableAuthStore{db: database}, legacySessionCookieName, secureCookies, authGuardURL, "collabtable")
// AUTHGUARD_URL, an optional bootstrap/override value: empty now means
// "pending" (see the package doc comment above and sharedauth's own
// "Auth-disabled mode" section) rather than disabled. authDisabled is
// AUTH_DISABLED, the explicit opt-out for local development or a standalone
// deployment that wants no AuthGuard integration at all -- it passes
// sharedauth.Disabled(), matching CollabTable's old unset-AUTHGUARD_URL
// behavior. "collabtable" is CollabTable's projectKey, letting an AuthGuard
// administrator restrict which accounts may log into CollabTable
// specifically -- handled entirely server-side by AuthGuard once passed
// here.
func newAuthService(database *DB, authGuardURL string, secureCookies bool, authDisabled bool) *sharedauth.Service {
var opts []sharedauth.ServiceOption
if authDisabled {
opts = append(opts, sharedauth.Disabled())
}
return sharedauth.NewWithStore(collabTableAuthStore{db: database}, legacySessionCookieName, secureCookies, authGuardURL, "collabtable", opts...)
}
// --- Device-sync API bearer token (unrelated to AuthGuard) ------------------
+12 -4
View File
@@ -42,10 +42,18 @@ func TestCollabTableAuthStoreSetLoginRequiredIsNoOp(t *testing.T) {
func TestNewAuthServiceBuildsAService(t *testing.T) {
// newAuthService must not panic given a nil *DB and no AuthGuard URL
// (auth-disabled mode) -- the store adapter's IsSetupClaimed/
// TryClaimSetup/UnclaimSetup only get called once a real request comes in
// and AuthGuard is enabled, so construction alone must be safe.
if service := newAuthService(nil, "", false); service == nil {
// ("pending" mode) -- the store adapter's IsSetupClaimed/TryClaimSetup/
// UnclaimSetup only get called once a real request comes in and AuthGuard
// is enabled, so construction alone must be safe.
if service := newAuthService(nil, "", false, false); service == nil {
t.Fatal("newAuthService() returned nil")
}
}
func TestNewAuthServiceBuildsADisabledService(t *testing.T) {
// authDisabled=true must also not panic given a nil *DB and no AuthGuard
// URL -- this is the explicit auth-disabled mode (sharedauth.Disabled()).
if service := newAuthService(nil, "", false, true); service == nil {
t.Fatal("newAuthService() returned nil")
}
}
+1 -1
View File
@@ -6,6 +6,6 @@ import (
)
func TestRegisterRoutes(t *testing.T) {
server := &Server{auth: newAuthService(nil, "", false)}
server := &Server{auth: newAuthService(nil, "", false, false)}
server.registerRoutes(http.NewServeMux(), webFS)
}
+17 -10
View File
@@ -57,18 +57,25 @@ func main() {
go database.pruneExpiredSessions(ctx)
go database.cleanupNotifications(ctx)
// AuthGuard is optional (see auth.go's top-of-file doc comment and
// sharedauth's own "Auth-disabled mode" section): an unset AUTHGUARD_URL
// means every request is treated as already authenticated, with nothing
// gated -- an explicit choice for local development or a standalone
// deployment, not a degraded fallback.
// AuthGuard integration has three states now (see auth.go's top-of-file
// doc comment and sharedauth's own "Auth-disabled mode" section): an
// AUTHGUARD_URL set is used immediately; unset with AUTH_DISABLED
// unset/false is "pending" (fully gated, failing closed until
// ProjectConfigurator's push arrives); AUTH_DISABLED=true is an explicit
// opt-out where every request is treated as already authenticated, with
// nothing gated -- for local development or a standalone deployment, not
// a degraded fallback.
authGuardURL := strings.TrimSpace(os.Getenv("AUTHGUARD_URL"))
if authGuardURL != "" {
authDisabled := strings.EqualFold(os.Getenv("AUTH_DISABLED"), "true")
switch {
case authDisabled:
fmt.Println("auth: DISABLED (AUTH_DISABLED=true) -- every request is treated as authenticated")
case authGuardURL != "":
fmt.Printf("auth: AuthGuard at %s\n", authGuardURL)
} else {
fmt.Println("auth: DISABLED (AUTHGUARD_URL not set) -- every request is treated as authenticated")
default:
fmt.Println("auth: PENDING (AUTHGUARD_URL not set) -- waiting for ProjectConfigurator to push an AuthGuard URL; auth calls fail closed until then")
}
auth := newAuthService(database, authGuardURL, strings.EqualFold(os.Getenv("COOKIE_SECURE"), "true"))
auth := newAuthService(database, authGuardURL, strings.EqualFold(os.Getenv("COOKIE_SECURE"), "true"), authDisabled)
// coreConfig holds the AuthGuard/CarrierNode URLs ProjectConfigurator pushes once this project
// is registered there (PUT /api/core-services/internal, see registerRoutes) -- AUTHGUARD_URL and
@@ -76,7 +83,7 @@ func main() {
// See Core/ProjectConfigurator/README.md's "Pushing core service info to other projects".
// auth.SetAuthGuardBaseURL retargets the live AuthGuard client sharedauth.Service holds
// internally on every push, so AuthGuard moving to a new URL takes effect without a restart -- it
// is a no-op when this service was constructed in auth-disabled mode (AUTHGUARD_URL unset above).
// is a no-op when this service was constructed in auth-disabled mode (AUTH_DISABLED=true above).
internalServiceSecret := strings.TrimSpace(os.Getenv("INTERNAL_SERVICE_SECRET"))
carrierNodeURL := strings.TrimSpace(os.Getenv("CARRIERNODE_URL"))
coreConfig := coreconfig.NewStore(coreconfig.Info{AuthGuardURL: authGuardURL, CarrierNodeURL: carrierNodeURL})