Problem Statement
JwtModule is registered independently in two modules with different fallback secrets:
api/src/auth/auth.module.ts:12 — secret: process.env.JWT_SECRET ?? "dev-secret-change-me"
api/src/gateways/gateways.module.ts:15 — secret: secret ?? "dev-insecure-secret-change-me"
Two different secrets, two JwtModule instances, two signOption configs. The GatewaysModule uses registerAsync while AuthModule uses register.
Evidence
// AuthModule: 15min expiry
JwtModule.register({ secret: process.env.JWT_SECRET ?? "dev-secret-change-me", signOptions: { expiresIn: "15m" } })
// GatewaysModule: 1h expiry, async registration
JwtModule.registerAsync({ useFactory: () => { ... return { secret: secret ?? "dev-insecure-secret-change-me", signOptions: { expiresIn: "1h" } } } })
Impact
Maintenance burden, inconsistent expiry times (auth tokens 15min vs gateway verification expecting 1h), and two fallback secrets. If either module's config is updated independently, JWTs may be rejected by one but accepted by the other.
Proposed Solution
- Create
api/src/config/jwt.config.ts with a shared JwtModule.registerAsync factory
- Import this shared config in both AuthModule and GatewaysModule
- Use consistent expiry (15min for access tokens)
- Single source of truth for JWT secret
Acceptance Criteria
File Map
api/src/config/jwt.config.ts — new shared config
api/src/auth/auth.module.ts — use shared config
api/src/gateways/gateways.module.ts — use shared config
Labels: refactoring
Priority: Medium | Difficulty: Intermediate | Estimated Effort: 1d
Labels: refactoring
Priority: Medium | Difficulty: Intermediate | Estimated Effort: 1d
Backlog ID: REPO-022
Problem Statement
JwtModule is registered independently in two modules with different fallback secrets:
api/src/auth/auth.module.ts:12—secret: process.env.JWT_SECRET ?? "dev-secret-change-me"api/src/gateways/gateways.module.ts:15—secret: secret ?? "dev-insecure-secret-change-me"Two different secrets, two JwtModule instances, two signOption configs. The GatewaysModule uses
registerAsyncwhile AuthModule usesregister.Evidence
Impact
Maintenance burden, inconsistent expiry times (auth tokens 15min vs gateway verification expecting 1h), and two fallback secrets. If either module's config is updated independently, JWTs may be rejected by one but accepted by the other.
Proposed Solution
api/src/config/jwt.config.tswith a sharedJwtModule.registerAsyncfactoryAcceptance Criteria
File Map
api/src/config/jwt.config.ts— new shared configapi/src/auth/auth.module.ts— use shared configapi/src/gateways/gateways.module.ts— use shared configLabels: refactoring
Priority: Medium | Difficulty: Intermediate | Estimated Effort: 1d
Labels: refactoring
Priority: Medium | Difficulty: Intermediate | Estimated Effort: 1d
Backlog ID: REPO-022