Add AUTH_DISABLED opt-out for sharedauth's new pending mode
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:
1 parent
a018f3da4c
commit
f723afa369
7 files changed
+84
-38
No files matched your search
+17
-10
@@ -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})
|
||||
|
||||
Reference in new issue
Block a user