Skip to content

fix: consolidate auth/role/admin guard implementations#50

Merged
MaryammAli merged 2 commits into
Proof-Stell:mainfrom
temiport25:fix/consolidate-auth-guards-issue-16
Jun 23, 2026
Merged

fix: consolidate auth/role/admin guard implementations#50
MaryammAli merged 2 commits into
Proof-Stell:mainfrom
temiport25:fix/consolidate-auth-guards-issue-16

Conversation

@temiport25

Copy link
Copy Markdown
Contributor

📋 Summary

Consolidates duplicate guard implementations and enforces a single canonical authenticated user shape across HTTP and WebSocket paths.

Type of Change

  • Bug Fix
  • Refactor

🎯 Requirements Checklist

Implementation

  • Feature requirements have been fully implemented
  • Code follows project architecture and conventions
  • Proper error handling has been added

Security

  • Authentication requirements are enforced
  • Authorization rules are properly implemented
  • No secrets, credentials, or environment-specific values are included

Testing

  • Unit tests added or updated
  • Existing tests pass successfully

📝 Detailed Changes

Added

  • AuthenticatedUser interface exported from auth/interfaces/request-with-user.ts as the single canonical user shape for both HTTP and WebSocket paths

Updated

  • WsJwtGuard now maps raw JWT sub claim → id field, aligning the WS user shape with the HTTP path (RequestWithUser)

Added

  • roles.guard.spec.ts — unit tests covering player access, admin access, player denied from admin route, and exact enum comparison guard

🧪 Testing Instructions

Steps to Verify

  1. npm run build — must pass with no errors
  2. npx jest --testPathPattern="roles.guard|admin.guard" — all 13 tests must pass

Expected Results

Build succeeds; 13 guard tests green.


🔗 Related Issues

Closes #16


⚠️ Breaking Changes

  • No breaking changes

📚 Documentation

  • No documentation changes required

- Export AuthenticatedUser interface as canonical user shape for both HTTP and WS
- Fix WsJwtGuard to map JWT sub claim to id field (canonical shape)
- Add RolesGuard unit tests covering player/admin access and exact enum comparison

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MaryammAli
MaryammAli merged commit 62b54b6 into Proof-Stell:main Jun 23, 2026
1 check 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.

Consolidate duplicate auth, role, and admin guard implementations

2 participants