Skip to content

Add auth guard and protect admin and DLQ endpoints#318

Merged
mikewheeleer merged 1 commit into
Talenttrust:mainfrom
Abolax123:security/admin-auth-guard
Jun 2, 2026
Merged

Add auth guard and protect admin and DLQ endpoints#318
mikewheeleer merged 1 commit into
Talenttrust:mainfrom
Abolax123:security/admin-auth-guard

Conversation

@Abolax123

Copy link
Copy Markdown

Closes #283

Admin Authentication Guard for DLQ & Deploy Endpoints

Issue

#283: Secure DLQ list and deploy status endpoints with admin authentication to prevent unauthorized access to sensitive operations and webhook replay capabilities.

Summary

This PR adds a comprehensive admin authentication guard (adminAuthGuard) middleware that secures all admin-only endpoints with two independent authentication methods: JWT with admin role verification and API key with admin-level scope validation. All DLQ management and blue-green deployment operations now require proven admin credentials before execution.

Changes

New Files

  • src/middleware/adminAuthGuard.ts — Admin auth guard middleware supporting JWT and API key authentication with scope/role validation
  • src/middleware/adminAuthGuard.test.ts — 17 test cases covering JWT validation, API key auth, scope checks, demo tokens, and error handling
  • src/routes/deploy.routes.ts — Deploy status, switch-green, and rollback endpoints protected by adminAuthGuard
  • src/routes/deploy.routes.test.ts — Deploy route tests with auth validation, credential redaction, and deployment state verification

Modified Files

  • src/index.ts

    • Protect GET /api/v1/jobs/dlq with adminAuthGuard
    • Protect POST /api/v1/jobs/dlq/reprocess with adminAuthGuard
    • Import adminAuthGuard middleware
  • src/app.ts — Register deploy router at /api/v1/admin/deploy prefix

  • src/config/env.schema.ts — Add JWT_SECRET validation for admin auth

  • src/logger.ts — Fix Set.flatMap() compatibility for credential redaction

  • docs/api-keys.md — Document admin scopes and JWT role requirements

Authentication Methods

JWT Bearer Tokens

Authorization: Bearer <jwt>

…issue Talenttrust#283)

- Implement adminAuthGuard middleware supporting JWT (admin role) and API key (admin scope)
- Protect GET /api/v1/jobs/dlq, POST /api/v1/jobs/dlq/reprocess endpoints
- Protect GET/POST /api/v1/admin/deploy/status, /switch-green, /rollback endpoints
- Add comprehensive test coverage for JWT validation, API key auth, and scope checks
- Add demo token support for test environments
- Redact credentials from logs to prevent accidental exposure
- Return RFC 7231 compliant 401/403 responses with secure error messages
- Fix logger.ts Set.flatMap() error
@drips-wave

drips-wave Bot commented Jun 1, 2026

Copy link
Copy Markdown

@Abolax123 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mikewheeleer mikewheeleer merged commit c47fec8 into Talenttrust:main Jun 2, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add authenticated admin auth guard for DLQ and deploy operator endpoints

2 participants