Skip to content

fix: enforce SIWS domain check in requireTeamMemberOrAdmin#86

Merged
sacha-l merged 1 commit into
developfrom
fix/team-middleware-domain-check
May 19, 2026
Merged

fix: enforce SIWS domain check in requireTeamMemberOrAdmin#86
sacha-l merged 1 commit into
developfrom
fix/team-middleware-domain-check

Conversation

@sacha-l
Copy link
Copy Markdown
Collaborator

@sacha-l sacha-l commented May 19, 2026

Summary

Security hardening. requireAdmin and requireOwnWallet verify the sign-in message domain against EXPECTED_DOMAIN (skippable via DISABLE_SIWS_DOMAIN_CHECK), but requireTeamMemberOrAdmin skipped that check entirely — a sign-in message produced for a different origin would still be accepted on team-gated routes.

This enables the same check there, so all three middleware are consistent. Preview/staging origins are handled the intended way — DISABLE_SIWS_DOMAIN_CHECK=true — rather than by omitting the check.

Addresses the backlog item "requireTeamMemberOrAdmin missing SIWS domain check" (docs/improvement-backlog.md, 2026-04-23).

Changes

  • server/api/middleware/auth.middleware.jsrequireTeamMemberOrAdmin calls authenticateRequest(..., { checkDomain: true }).
  • auth.middleware.test.js — adds a 403-on-domain-mismatch test for requireTeamMemberOrAdmin.

Test plan

  • cd server && npm test162 tests pass (21 files), including the new domain-mismatch case; all existing requireTeamMemberOrAdmin cases (which sign on localhost) still pass.

Note

Live deployments must have EXPECTED_DOMAIN set correctly (or DISABLE_SIWS_DOMAIN_CHECK=true for previews) — same requirement the other two middleware already had.

🤖 Generated with Claude Code

requireAdmin and requireOwnWallet verify the sign-in message domain
against EXPECTED_DOMAIN (skippable via DISABLE_SIWS_DOMAIN_CHECK);
requireTeamMemberOrAdmin skipped it entirely. Enable it there too so
all three middleware are consistent — preview/staging origins are
handled by DISABLE_SIWS_DOMAIN_CHECK, not by omitting the check.

Adds a domain-mismatch test. Server: 162 tests pass.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stadium Ready Ready Preview, Comment May 19, 2026 5:49pm

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.

1 participant