Skip to content

fix(auth): two-factor release review fixes - #10748

Merged
waleedlatif1 merged 4 commits into
stagingfrom
fix/two-factor-release-review
Dec 3, 2026
Merged

waleedlatif1 merged 4 commits into
stagingfrom
fix/two-factor-release-review

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Fixes from the release review (#10740) on the two-factor work:

  • Sign-in, setup and step-up read the organization's 2FA requirement fresh. They used the per-process 60s cache, so a member signing in on another instance right after an admin turned the requirement on could skip enrollment. getTwoFactorState now folds the requirement into its existing user/member query (one query when the requirement is off); the per-request sweep keeps the cache
  • The per-request sweep (enforceTwoFactorRequirement) also revokes the member's OAuth grants when it ends a session, so an MCP grant minted from that session doesn't outlive it
  • The sweep fails open consistently on a read error (it now matches what a failed membership read already did). Returning null there sends the app's stale-session recovery into a full sign-out, so a DB blip would end compliant sessions; the fail-closed controls are sign-in and turning the requirement on
  • Platform-admin 2FA reset ends cached sessions too: new revokeAllUserSessions in lib/organizations/members/revocation.ts uses revokeUserSessionsTx for members (moves the org cookie-cache version, like removal and suspension), spares impersonation sessions for everyone, reads membership inside the transaction

Type of Change

  • Bug fix

Testing

  • lib/auth/two-factor/guard.integration.ts 20/20 against real Postgres + the Better Auth handler. New tests: enrollment challenged while this instance caches the requirement as off; sweep ends the session and OAuth grants; admin reset makes the member's cached session cookie stop resolving. Each verified red against the pre-fix code
  • lib/organizations/members tests, biome, api-validation strict, boundaries, client-boundary, source-conventions, comment-hygiene, test-patterns, file-names, utils, explicit-any, permission-group-enforcement, tool-registry-boundary, type-check (pre-push); full check:audits and suites in CI
  • /simplify and the applicable /cleanup passes (comments, test-audit) applied

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 3, 2026 10:53pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 5 files

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/auth/auth.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 9cadc95 into staging Dec 3, 2026
152 of 154 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/two-factor-release-review branch December 3, 2026 23:44

This branch was previously deployed

1 inactive deployment
Preview — 741095b6 Deployed Dec 3, 2026 by vercel[bot]
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