Implement Unified API Gateway Proxy for Secure Admin Actions#3
Open
google-labs-jules[bot] wants to merge 1 commit into
Open
Conversation
Added a server-side API proxy gateway at /api/admin. Updated dashboard admin page to route requests via the secure proxy. Added a gateway secret mechanism to Nginx/backend to only accept authenticated proxied requests. Protected /admin and /dashboard routes via next-auth token checking in proxy.ts. Removed direct client side exposure of port 4003.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Why This Change is Necessary
Previously, the administrative dashboard communicated directly from the client's browser to the unauthenticated backend orchestration service on port
4003. This architecture exposed critical Docker orchestration capabilities (such as listing, starting, and stopping containers) to unauthorized network actors and bypassed authentication checks entirely.To secure our infrastructure and prevent unauthorized container tampering, we have introduced a Unified API Gateway Proxy. This architecture centralizes authorization logic, hides internal management ports, and ensures that only authenticated administrators can trigger container orchestration commands.
What Was Changed
1. Next.js Routing & Session Middleware (
my-portfolio/middleware.ts)/adminand/dashboard) are immediately redirected to/login.2. Server-Side API Gateway Proxy Router (
my-portfolio/app/api/admin/[[...path]]/route.ts)admin-service.X-Gateway-Secretheader to the proxied requests to verify their origin.401 Unauthorizedstatus for unverified sessions.3. Ingress Secret Validation (
my-portfolio/server/admin-service/index.js)admin-service.X-Gateway-Secretheader matching the environment'sGATEWAY_SECRET.403 Forbiddenresponse.4. Client-Side API Migration (
my-portfolio/app/admin/page.tsx)4003). All administrative actions now utilize relative API routes (e.g.,/api/admin/containers), preventing the internal port from being exposed to the browser.Verification and Acceptance Criteria
/adminor/dashboardredirects to/login.4003.admin-servicewithout the correct gateway header are rejected with403 Forbidden.