Skip to content

Clean separation of Frontend And Backend

Pre-release
Pre-release

Choose a tag to compare

@ushakrishnan ushakrishnan released this 29 Sep 19:38

What’s complete (done)
Frontend/back-end boundary enforced: the frontend is a thin client that does not perform direct DB access or client-side DB initialization; it only calls backend APIs.
Client secrets removed: Cosmos/AI keys and any server-only secrets were removed from frontend sources and .env.example.
Server owns secrets: all DB and AI credentials are centralized in .env (not checked in).
Vite cleanup: removed server-side use of VITE_* for DB and moved client-safe Vite vars to the frontend example files.
Scripts & tooling updated: backend/scripts/* were updated to use canonical server env names (e.g., ADMIN_SERVER_URL, DEV_SERVER_PORT).
Build / dist rebuilt: backend TypeScript artifacts were rebuilt and patched so no server-side VITE_ fallbacks remain.
Tests fixed: the AI unit tests that were failing due to a bad fetch stub were corrected and all backend unit tests pass locally.
Admin auth scaffolding added: jose was added as a dependency and there is middleware scaffolding in the repo for token verification and actor identification (see the security doc for the filenames added).
What’s not complete / still pending (token/JWT and related)
JWT production configuration (pending): production-grade JWKS endpoint(s) and signing key management are not fully configured or verified in production environments (you need to set AUTH_JWKS_URI / equivalent and secure the signing keys in a vault).
JWKS caching & rotation handling (not implemented): middleware needs JWKS caching, key rotation handling, and robust fallback behaviors for stale/rotating keys.
Token policies (not enforced yet): short-lived access tokens, refresh token design or rotating service credentials, and audience/issuer enforcement need to be established and deployed.
Secure token transport (not completed): using secure, HttpOnly cookies (with SameSite/Secure) for token transport where appropriate is not implemented by default.
Key rotation / secret vaulting (pending): moving signing keys and secrets into an actual secrets manager (Azure Key Vault / HashiCorp Vault), and rotating any keys that may have been exposed during development.
Integration tests for auth (missing): integration tests that assert 401/403 for unauthenticated/unauthorized calls and 200 for valid tokens are not yet in place.
JWKS monitoring / alerting (not implemented): no monitoring/alerts exist for JWKS fetch failures, signature verification anomalies, or unexpected key rotation events.
CI/test token handling (partially done): HS256 fallback for tests may be present, but CI must be configured with secure test secrets (e.g., AUTH_JWT_SECRET) and the tests adjusted to use them safely.
Full admin enforcement audit (partial): some admin routes were tightened, but a full audit to confirm every sensitive endpoint rejects header-only/unsafe identification in production is still recommended.
Quick recommended next steps (concrete, minimal)
Immediately rotate any signing keys that may have been used in development and put production keys into a vault.
Configure and test a production JWKS URI (AUTH_JWKS_URI) in a staging environment and implement JWKS caching with key rotation handling. I can add a small middleware implementation and unit/integration tests for this.
Add integration tests that validate 401/403 behavior for admin endpoints and wire CI to provide a test HS256 secret (only for CI/dev).
Enforce secure transport (HTTPS) and review cookie usage; add SameSite/Secure/HttpOnly on any cookies used for tokens.