Make AuthGuard integration decouple from knowing the URL at startup

Every language's AuthGuard client/service used "no URL at construction"
to mean "auth disabled forever" - a live SetBaseUrl/setBaseUrl push from
ProjectConfigurator could only ever retarget an *already-enabled* client,
never turn one on for the first time. That made AUTHGUARD_URL a de-facto
required env var everywhere, even though ProjectConfigurator can push it
live after startup.

- Go: shared/backend/auth's New/NewWithStore now default to a "pending"
  Service (still enabled, fails closed until a URL arrives) instead of
  disabled when authGuardURL is empty; add an explicit Disabled() option
  for the genuine standalone/local-dev opt-out.
- Python/Node/Java: add setBaseUrl/set_base_url to each AuthClient so a
  client built with an empty base URL can be retargeted in place once a
  URL is pushed, the same as the Go client already supported.
- Python/Node: add a coreconfig module (Info/Store), the framework-agnostic
  equivalent of shared/backend/coreconfig (Go), for services in those
  languages to receive ProjectConfigurator's core-services push at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Gabriel20xxandClaude Sonnet 5 committed 2026-09-14 09:35:45 +02:00
1 parent c09957189f
commit dcfdb3d7af
18 files changed
+747 -46

No files matched your search

+21
View File
@@ -87,6 +87,27 @@ export class AuthClient {
return this.projectKey ? { [PROJECT_KEY_HEADER]: this.projectKey } : {};
}
/**
* Atomically replaces the AuthGuard base URL this client calls,
* normalizing it the same way the constructor does. Mirrors Go's
* authclient.Client.SetBaseURL / Python's AuthClient.set_base_url / Java's
* AuthClient#setBaseUrl: the intended use is a project's own
* coreconfig-equivalent push handler calling this on its live AuthClient
* instance so a freshly pushed AuthGuard URL takes effect on the client's
* very next call with no restart - including the very first URL a client
* constructed with baseUrl "" (a "pending" client, not yet configured but
* still meant to be used) ever receives. A blank baseUrl is ignored
* (leaving the previous value in place) rather than leaving the client
* unable to reach AuthGuard at all.
* @param {string} baseUrl
*/
setBaseUrl(baseUrl) {
const normalized = AuthClient._normalizeBaseUrl(baseUrl);
if (normalized) {
this.baseUrl = normalized;
}
}
static _normalizeBaseUrl(baseUrl) {
const trimmed = String(baseUrl ?? '').trim().replace(/\/+$/, '');
if (!trimmed) return trimmed;