Skip to content

[ENG-4086] feat(custom-auth): multi-step custom auth flow (admin consent)#1628

Open
RajatPawar wants to merge 4 commits into
mainfrom
rajatspawar/universal-custom-auth
Open

[ENG-4086] feat(custom-auth): multi-step custom auth flow (admin consent)#1628
RajatPawar wants to merge 4 commits into
mainfrom
rajatspawar/universal-custom-auth

Conversation

@RajatPawar

@RajatPawar RajatPawar commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

Adds the consumer-facing multi-step custom auth flow to the UI library — for providers whose ProviderInfo has customOpts.multiStep (e.g. Microsoft Admin Consent).

  • MultiStepCustomAuthFlow — POSTs the form to /custom-auth/connect; while the server returns a redirect, opens it in a popup and resumes with the params the callback forwards (via postMessage, origin-checked) until the server returns a connection.
  • MultiStepCustomAuthContent — a fieldType-aware form (text / password / select) rendered from customOpts.inputs.
  • form/Select — a native select primitive (reuses the shared input styles).
  • useCustomAuthConnectMutation — thin react-query wrapper over connectionApi.customAuthConnect.
  • ProtectedConnectionLayout — the only existing file touched: an additive sub-branch routing custom + multiStep here; every current provider still hits the unchanged single-step CustomAuthFlow.

Testing

Screenshot 2026-07-14 at 1 56 33 PM Screenshot 2026-07-14 at 1 56 57 PM Screenshot 2026-07-14 at 1 57 11 PM Screenshot 2026-07-14 at 3 28 23 PM ## Add-only / no regression The existing single-step custom auth and all other auth flows are unchanged — the multi-step path is a new, additively-routed branch.

Depends on

  • Bundles the regenerated OpenAPI client (customAuthConnect, CustomAuthConnectRequest/Response, CustomAuthInput.fieldType/options, customOpts.multiStep) from the auto openapi-sync [auto] Update openapi dependency #1627. Once [auto] Update openapi dependency #1627 merges, I'll rebase to drop that commit so the diff is just the feature.
  • Server /custom-auth/connect (server #6747) + connectors registry (connectors #3184) at runtime.

🤖 Generated with Claude Code

ampersand-ops and others added 2 commits July 14, 2026 00:38
…NG-4086]

Add the consumer-facing driver for providers whose ProviderInfo has
customOpts.multiStep. It POSTs the form to /custom-auth/connect and, while the
server returns a redirect, opens it in a popup and resumes with the params the
callback forwards, until the server returns a connection.

Add-only, no changes to the existing single-step custom auth:
- MultiStep/MultiStepCustomAuthFlow.tsx: the popup + postMessage resume loop.
- MultiStep/MultiStepCustomAuthContent.tsx: a fieldType-aware form
  (text/password/select) rendered from customOpts.inputs.
- form/Select: a native select form primitive (reuses the shared input styles).
- useCustomAuthConnectMutation: thin react-query wrapper over connectionApi.
- ProtectedConnectionLayout: the only existing file touched — an additive
  sub-branch that routes custom+multiStep here; every current provider (none
  set multiStep) still hits the unchanged CustomAuthFlow.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@linear

linear Bot commented Jul 14, 2026

Copy link
Copy Markdown

ENG-4086

@RajatPawar
RajatPawar requested review from a team, dionlow, eberle1080 and laurenzlong and removed request for a team, dionlow and eberle1080 July 15, 2026 23:56
/**
* Drives a multi-step custom auth flow: submit the form to /custom-auth/connect,
* and while the server returns a redirect, open it in a popup and resume with the
* params the callback forwards, until the server returns a connection.

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.

Suggested change
* params the callback forwards, until the server returns a connection.
* params the callback forwards, until the server returns a successfully created Connection.

const onMessage = (ev: MessageEvent<CustomAuthCallbackMessage>) => {
// Accept only messages from the API origin (where the callback is served).
if (ev.origin !== AMP_SERVER) return;
if (ev.data?.source !== "ampersand-custom-auth") return;

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.

put "ampersand-custom-auth" into a constant, and also use it in line 25 above

RajatPawar and others added 2 commits July 22, 2026 12:07
…nt + doc wording

- Hoist "ampersand-custom-auth" message source into CALLBACK_MESSAGE_SOURCE,
  reused by the message type (via typeof) and the listener guard
- Clarify flow JSDoc wording

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…elect

- Render FieldTypeSelect via the shared ui-base/ComboBox (as field mapping does)
  instead of a bespoke form/Select; delete form/Select
- Disable Next until every custom input is filled; a select must resolve to a
  declared option (rejects the empty placeholder)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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