Skip to content

fix(auth): Preserve explicit invitation acceptance through MFA - #126028

Merged
evanpurkhiser merged 1 commit into
masterfrom
git/fix-auth-preserve-explicit-invitation-acceptance-through-mfa
Sep 30, 2026
Merged

evanpurkhiser merged 1 commit into
masterfrom
git/fix-auth-preserve-explicit-invitation-acceptance-through-mfa

Conversation

@evanpurkhiser

Copy link
Copy Markdown
Member

Keep invitation acceptance compatible with the existing screen while the composed authentication flow rolls out.

Clients can opt in with GET /api/0/accept-invite/{organization}/{member}/{token}/?acceptance=explicit. The opt-in is stored with the pending invitation in the session. MFA enrollment then leaves that invitation pending for an explicit acceptance POST. Clients using the default request retain automatic acceptance after enrollment. Session cleanup removes the opt-in, and loading another invitation with the default behavior resets it.

The opted-in request also preserves a pending MFA login challenge when the invitation page is reloaded. Authentication and acceptance validation remain unchanged, and organization SSO continues to accept through its provider pipeline.

Deploy this backend change before the frontend opt-in in #125910.

Verification: 67 scoped backend tests pass, covering existing automatic acceptance, explicit TOTP/SMS/security-key enrollment, subsequent explicit acceptance, invalid invitations, session scoping, and pending MFA preservation. Backend typing and lint checks pass. The composed flow was also tested against this backend with all eight browser acceptance journeys passing.

@evanpurkhiser
evanpurkhiser requested a review from a team as a code owner September 30, 2026 14:13
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 30, 2026
Let the composed invitation page keep invitations pending after MFA
enrollment while preserving automatic acceptance for existing clients.
Retain pending MFA challenges when the opted-in page is reloaded.
@evanpurkhiser
evanpurkhiser force-pushed the git/fix-auth-preserve-explicit-invitation-acceptance-through-mfa branch from a6813cf to 8fa04f9 Compare September 30, 2026 14:24
)
auth.initiate_login(self.request, next_url=url)
# Reloading the composed page must preserve an in-progress MFA challenge.
if not (explicit_acceptance and auth.get_pending_2fa_user(request) is not None):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This conditional is weird. if not explicit_acceptance or auth.get_pending_2fa_user(request) is None would be more readable. I believe the boolean logic is the same. If explicit_acceptance is off or there is no pending 2fa user continue through the conditional.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll leave it as is for now, this code will be removed pretty fast

@evanpurkhiser
evanpurkhiser enabled auto-merge (squash) September 30, 2026 14:28
@evanpurkhiser
evanpurkhiser merged commit 1ef8153 into master Sep 30, 2026
68 checks passed
@evanpurkhiser
evanpurkhiser deleted the git/fix-auth-preserve-explicit-invitation-acceptance-through-mfa branch September 30, 2026 14:34
evanpurkhiser added a commit that referenced this pull request Sep 30, 2026
Move organization invitation acceptance under the branded authentication
layout and compose the invitation account badge, account authentication,
and status components introduced earlier in this stack.

Signed-out users can create an account or sign in, including MFA, within
the invitation screen. Authentication refreshes the invitation before
presenting acceptance. Organization SSO accepts the invitation through
the provider pipeline and lands in the organization. Signed-in users see
the account they are accepting with and can switch accounts inline.

`useInvitationFlow` owns fetching, authentication completion, account
switching, acceptance, and the derived view state. The page renders that
state with a shared `InvitationLayout`, while `getInvitationStep`
selects the authentication or acceptance step independently of the
status component.

The invitation query opts into explicit acceptance. MFA enrollment in a
separate tab leaves the invitation pending, and returning to the
invitation refetches its requirements before offering acceptance.
Temporary invitation, organization-config, and authentication-config
failures show a retry action; invalid or expired invitations retain
their account-switch action. A failed refresh after logout keeps the
previous account hidden.

Retain the legacy invitation component and its unit tests for a
follow-up cleanup.

Backend dependency: #126028 is merged and included in this stack’s base,
so browser CI exercises the compatibility behavior. It preserves default
automatic acceptance for existing clients while enabling explicit
acceptance and preserving pending MFA challenges for this flow. Deploy
that backend change before landing this frontend change.

Verification: all eight browser acceptance journeys pass using the
default auth configuration against that backend: signed-in acceptance,
new-account registration, password sign-in, MFA sign-in, organization
SSO, switching accounts and signing in again, refreshing during a
pending MFA challenge, and required MFA enrollment in a second tab
followed by returning and explicitly accepting without a page reload.
Registration and sign-in assert the membership remains pending before
acceptance. Page integration tests cover transient-load retries,
organization-config retries, failed focus refreshes, and failed
refreshes after logout. The scoped frontend suite has 39 passing tests;
frontend type-checking and lint checks pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants