Add auth guard and protect admin and DLQ endpoints#318
Merged
mikewheeleer merged 1 commit intoJun 2, 2026
Conversation
…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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 validationsrc/middleware/adminAuthGuard.test.ts— 17 test cases covering JWT validation, API key auth, scope checks, demo tokens, and error handlingsrc/routes/deploy.routes.ts— Deploy status, switch-green, and rollback endpoints protected by adminAuthGuardsrc/routes/deploy.routes.test.ts— Deploy route tests with auth validation, credential redaction, and deployment state verificationModified Files
src/index.tsGET /api/v1/jobs/dlqwithadminAuthGuardPOST /api/v1/jobs/dlq/reprocesswithadminAuthGuardsrc/app.ts— Register deploy router at/api/v1/admin/deployprefixsrc/config/env.schema.ts— AddJWT_SECRETvalidation for admin authsrc/logger.ts— Fix Set.flatMap() compatibility for credential redactiondocs/api-keys.md— Document admin scopes and JWT role requirementsAuthentication Methods
JWT Bearer Tokens
Authorization: Bearer <jwt>