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

@@ -0,0 +1,54 @@
import unittest
from shared_backend.coreconfig import Info, Store
class StoreDefaultsTests(unittest.TestCase):
def test_seeds_from_fallback(self):
store = Store(Info(auth_guard_url="http://auth.example.com", carrier_node_url="http://carrier.example.com"))
info = store.get()
self.assertEqual(info.auth_guard_url, "http://auth.example.com")
self.assertEqual(info.carrier_node_url, "http://carrier.example.com")
self.assertEqual(info.carrier_node_urls, ["http://carrier.example.com"])
def test_defaults_to_empty(self):
store = Store()
info = store.get()
self.assertEqual(info.auth_guard_url, "")
self.assertEqual(info.carrier_node_urls, [])
class StoreSetTests(unittest.TestCase):
def test_partial_push_does_not_clobber_other_field(self):
store = Store(Info(auth_guard_url="http://auth.example.com", carrier_node_url="http://carrier.example.com"))
store.set(Info(carrier_node_url="http://carrier2.example.com"))
info = store.get()
self.assertEqual(info.auth_guard_url, "http://auth.example.com")
self.assertEqual(info.carrier_node_url, "http://carrier2.example.com")
def test_blank_auth_guard_url_ignored(self):
store = Store(Info(auth_guard_url="http://auth.example.com"))
store.set(Info(auth_guard_url=""))
self.assertEqual(store.auth_guard_url, "http://auth.example.com")
def test_on_update_called_with_resulting_info(self):
store = Store()
seen = []
store.on_update(seen.append)
store.set(Info(auth_guard_url="http://auth.example.com"))
self.assertEqual(len(seen), 1)
self.assertEqual(seen[0].auth_guard_url, "http://auth.example.com")
def test_from_json_round_trip(self):
payload = {
"authGuardUrl": "http://auth.example.com",
"carrierNodeUrl": "http://carrier.example.com",
"carrierNodeUrls": ["http://carrier.example.com", "http://carrier2.example.com"],
}
info = Info.from_json(payload)
self.assertEqual(info.carrier_node_urls, ["http://carrier.example.com", "http://carrier2.example.com"])
self.assertEqual(info.to_json()["carrierNodeUrl"], "http://carrier.example.com")
if __name__ == "__main__":
unittest.main()