Files
shared/packages/java-backend
Gabriel20xxandClaude Sonnet 5 dcfdb3d7af 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>
2026-09-14 09:35:45 +02:00
..

com.gabriel20xx.shared:java-backend

Shared account-management, TOTP, admin reset-code, and AuthGuard client primitives for Java services:

  • Roles - shared account-management roles (superadmin/admin/user) and permission checks;
  • Totp - RFC 6238 TOTP secret generation, provisioning URIs, and verification;
  • ResetManager - a short-lived, one-time admin reset-code primitive printed to the server console;
  • AuthClient - a client for a centralized AuthGuard instance's GET /api/session/validate, for services that want one shared identity instead of their own local user table. Mirrors shared/backend/authclient (Go) and shared/packages/node-backend/src/authclient.js (Node) - keep the three in sync if any of them changes shape. Additive: no project is wired up to use it just because this class exists. setBaseUrl(url) retargets an existing client's AuthGuard URL in place - the natural target for a ProjectConfigurator core-services push handler - so a client can be constructed with new AuthClient("") (usable right away, failing closed with IllegalStateException until a real URL arrives) rather than needing one known up front. Unlike the Go/Python/Node siblings, this package has no coreconfig module of its own: MegaBasterd, its only consumer, wires the PUT /api/core-services/internal route directly against a plain field holding the current AuthGuardUrl.

How this package is actually consumed

Unlike its node-backend/python-backend siblings, this package is not published and installed as a dependency. Its real, already-identified consumer - MegaBasterd - instead adds this package's src/main/java as an extra source directory of its own Maven build, via the build-helper-maven-plugin "add-shared-java-auth" execution in MegaBasterd/pom.xml, and compiles these .java files straight into its own jar. That pom pins <maven.compiler.source>/<target> to 1.8, which is why every class in this package targets Java 8 and none of them (including AuthClient) take on a dependency beyond the JDK - both would break that real build.

This package's own pom.xml exists only so it can be built and tested in isolation during development; it plays no part in how MegaBasterd (or any future consumer that adopts the same source-inclusion approach) actually builds.

Testing

Run mvn test from this package.