Skip to content

feat(auth0-server-js): add multi-factor authentication (MFA) support#164

Open
amitsingh05667 wants to merge 37 commits into
mainfrom
feat/server-js-mfa-support
Open

feat(auth0-server-js): add multi-factor authentication (MFA) support#164
amitsingh05667 wants to merge 37 commits into
mainfrom
feat/server-js-mfa-support

Conversation

@amitsingh05667
Copy link
Copy Markdown
Member

@amitsingh05667 amitsingh05667 commented Apr 15, 2026

This multi-factor authentication (MFA) support is split into two PR's as mentioned below -

Summary

  • Introduce ServerMfaClient module with comprehensive Multi-Factor Authentication (MFA) support for server-side flows
  • Add four public methods: listAuthenticators(), enrollAuthenticator(), challengeAuthenticator(), and verify() (verifies MFA challenge and saves tokens into session)
  • Integrate ServerMfaClient as serverClient.mfa property on ServerClient

Design decisions

  • New feature only: Does not introduce breaking changes to existing functionality
  • Dedicated error classes: Specific error classes for each MFA operation (enrollment, listing, challenge, verification) for granular error handling
  • Server-side only: MFA verify() automatically saves tokens into the user's session after successful verification, keeping credentials server-side
  • Delegates to auth0-auth-js: listAuthenticators, enrollAuthenticator, and challengeAuthenticator delegate directly to the underlying AuthClient.mfa, keeping transport logic in one place

Test plan

  • 28 unit tests covering all 4 operations in server-mfa-client.spec.ts
  • 228 total tests passing across 9 test files
  • Error path coverage
  • npm run build passes
  • Tested end-to-end against a real tenant

@amitsingh05667 amitsingh05667 changed the title feat(auth0-server-js): add multi-factor authentication (MFA) support feat(auth0-server-js): POC add multi-factor authentication (MFA) support Apr 21, 2026
Copy link
Copy Markdown
Contributor

@subhankarmaiti subhankarmaiti left a comment

Choose a reason for hiding this comment

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

@amitsingh05667 here are some key point you can consider

  1. we should Introduce MFA related error classes for better DX
  2. also please update examples

Comment thread packages/auth0-server-js/src/mfa/server-mfa-client.ts Outdated
Comment thread packages/auth0-server-js/src/mfa/types.ts Outdated
Comment thread packages/auth0-server-js/src/mfa/types.ts Outdated
amitsingh05667 and others added 19 commits April 29, 2026 12:37
…auth0-auth-js into feat/server-js-mfa-support
…auth0-auth-js into feat/server-js-mfa-support
@amitsingh05667 amitsingh05667 marked this pull request as ready for review May 18, 2026 04:44
Comment thread packages/auth0-server-js/src/mfa/server-mfa-client.ts Outdated
Comment thread packages/auth0-auth-js/src/auth-client.ts
Comment thread packages/auth0-auth-js/src/mfa/index.ts
Comment thread packages/auth0-server-js/src/mfa/server-mfa-client.ts Outdated
Comment thread packages/auth0-server-js/src/mfa/server-mfa-client.ts
Comment thread packages/auth0-server-js/src/mfa/server-mfa-client.ts Outdated
subhankarmaiti
subhankarmaiti previously approved these changes May 28, 2026
nandan-bhat
nandan-bhat previously approved these changes Jun 1, 2026
@nandan-bhat nandan-bhat changed the title feat(auth0-server-js): POC add multi-factor authentication (MFA) support feat(auth0-server-js): add multi-factor authentication (MFA) support Jun 1, 2026
@nandan-bhat nandan-bhat dismissed stale reviews from subhankarmaiti and themself June 1, 2026 09:09

I have an additional comment. So I am dismissing my approval.

@nandan-bhat
Copy link
Copy Markdown
Contributor

@amitsingh05667
Create separate PRs for auth0-auth-js and auth0-server-js.
Release auth0-auth-js changes first, and use the released version in auth0-server-js.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Warning

Review limit reached

@amitsingh05667, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ff457196-e135-427e-aa81-349db80a065d

📥 Commits

Reviewing files that changed from the base of the PR and between 277ca4b and 3448c5a.

📒 Files selected for processing (8)
  • packages/auth0-server-js/MFA.md
  • packages/auth0-server-js/src/index.ts
  • packages/auth0-server-js/src/mfa/index.ts
  • packages/auth0-server-js/src/mfa/server-mfa-client.spec.ts
  • packages/auth0-server-js/src/mfa/server-mfa-client.ts
  • packages/auth0-server-js/src/mfa/types.ts
  • packages/auth0-server-js/src/server-client.ts
  • packages/auth0-server-js/src/test-utils/tokens.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/server-js-mfa-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

nandan-bhat
nandan-bhat previously approved these changes Jun 5, 2026
@nandan-bhat nandan-bhat dismissed their stale review June 5, 2026 06:35

I am reviewing it again.

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.

3 participants