Skip to content

[BE-31] Add IP Whitelist Guard for restricting admin endpoint access #970

@devwums

Description

@devwums

Problem

Admin endpoints are accessible from any IP address. There is no network-level access restriction to limit exposure of admin operations.

Proposed Solution

Create backend/cntr/ip-whitelist.guard.ts — a NestJS CanActivate guard that reads ADMIN_IP_WHITELIST (comma-separated IPs) from the config, extracts the client IP from request.ip, and returns true only if the IP is in the list. If the env var is empty or unset, the guard allows all traffic (fail-open). All implementation must live inside backend/cntr/.

Acceptance Criteria

  • File at backend/cntr/ip-whitelist.guard.ts
  • Reads ADMIN_IP_WHITELIST (comma-separated string)
  • Trims whitespace around each IP in the list
  • Allows all traffic when env var is unset or empty
  • Throws ForbiddenException for non-whitelisted IPs
  • Unit test at backend/cntr/ip-whitelist.guard.spec.ts covering: matching IP, non-matching IP, empty whitelist

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions