Skip to content

fix(users): protect GET /users and /users/:id with auth and redact PII (#64) - #68

Open
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/64-users-auth-pii-redaction
Open

fix(users): protect GET /users and /users/:id with auth and redact PII (#64)#68
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/64-users-auth-pii-redaction

Conversation

@ghzhost

@ghzhost ghzhost commented Aug 16, 2026

Copy link
Copy Markdown

Overview

Fixes #64 by enforcing authentication and scoped PII serialization across GET /users and GET /users/:id.

Changes

  1. Authentication: Applied @UseGuards(JwtAuthGuard) and @ApiBearerAuth() at the UsersController class level so that GET /users and GET /users/:id require valid authentication.
  2. PII Protection & DTO Mapper: Created UserResponseMapper (toPublicUser in src/users/user-response.mapper.ts) following the toPublicEscrow mapper pattern. Sensitive PII such as email is stripped for arbitrary callers and only preserved for the profile owner (user.id === caller.userId) or admins/maintainers.
  3. Tests: Added comprehensive test suites:
    • src/users/user-response.mapper.spec.ts: verifies redaction rules, owner visibility, admin visibility, and nested GitHub account serialization.
    • src/users/users.controller.spec.ts: verifies controller-level redaction for list and findOne operations.

Closes #64

MergeFi#64)

- Add JwtAuthGuard to UsersController to require authentication across all endpoints
- Add UserResponseMapper (toPublicUser) DTO serializer pattern to strip email and sensitive fields
- Expose email only to the owner (matching userId) or administrative roles
- Add unit tests for UserResponseMapper and UsersController
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

GET /users and GET /users/:id are fully unauthenticated, exposing every user's email and other PII with no field-level restriction

1 participant