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_KEY and JWT_ISSUER values.

  • Critical for diagnosing mismatched secrets between identity-backend and dependent microservices (e.g., logging-backend).


Usage

Endpoint:

GET /debug-env

Behavior

  1. Expose JWT Configuration

    • Returns JSON containing the active JWT_SECRET_KEY and JWT_ISSUER.

    • Does not expose sensitive keys in production-grade systems; use only in staging/dev or behind admin access.

  2. 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).

  3. Debugging Token Failures

    • Use in tandem with /ping and /verify to pinpoint configuration mismatches:

      • If /ping works but /verify fails → likely a secret mismatch.

      • Compare JWT_SECRET_KEY output 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

Popular posts from this blog

Feature: Audit log for one login, and identity service

Getting started - Build your data science lab environment

QA - Run #1 - Results