Solution Design: /debug-env Endpoint
Purpose
The /debug-env endpoint provides visibility into runtime configuration for debugging inter-service JWT issues.
-
Returns current
JWT_SECRET_KEYandJWT_ISSUERvalues. -
Critical for diagnosing mismatched secrets between identity-backend and dependent microservices (e.g., logging-backend).
Usage
Endpoint:
GET /debug-env
Behavior
-
Expose JWT Configuration
-
Returns JSON containing the active
JWT_SECRET_KEYandJWT_ISSUER. -
Does not expose sensitive keys in production-grade systems; use only in staging/dev or behind admin access.
-
-
Compare Across Services
-
Must match between identity-backend and every service validating its tokens:
-
JWT_SECRET_KEY— ensures signature validation succeeds. -
JWT_ISSUER— ensures correct trust anchor (identity-backend).
-
-
-
Debugging Token Failures
-
Use in tandem with
/pingand/verifyto pinpoint configuration mismatches:-
If
/pingworks but/verifyfails → likely a secret mismatch. -
Compare
JWT_SECRET_KEYoutput from identity-backend vs. logging-backend/debug-env.
-
-
Response Example
{
"JWT_SECRET_KEY": "your_shared_secret",
"JWT_ISSUER": "identity-backend"
}
Operational Role
-
Quick Validation:
Confirms environment variables are loaded correctly without SSHing into the server. -
Root Cause Analysis:
When token validation fails (Signature verification failed), this endpoint is the fastest way to confirm if secrets are mismatched. -
Ops Monitoring:
Can be polled post-deploy to verify cPanel environment variables persisted correctly after updates.
Comments
Post a Comment