Repository navigation
Sign in to embedded apps with a host token - #222
Conversation
Pages such as a Microsoft Teams tab can now show published apps in a frame. The provider's sign-in page refuses to render in frames and the regular Lax session cookie is not sent there, so a framed navigation without a session goes to a sign-in page on the auth host instead. That page asks its embedding page for a host token through postMessage, and the proxy verifies it against the organization's Entra client and tenant, resolves groups through on-behalf-of Graph access and issues a partitioned session that expires with the token. Organizations list the hosts that may embed their apps in their settings. The list becomes the apps' frame-ancestors and is published only for Entra app identity.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | d3e958d | Nov 19 2026, 09:22 AM |
The auth worker selected organizations on the auth host only for the regular OAuth paths, so the embedded sign-in page and its session check returned 404 in deployments. Embedded sessions now span numbered cookies like regular sessions, so identities with many groups stay within the browser's per-cookie limit, and a new sign-in expires leftover chunks. Accounts without a mailbox use their sign-in name as email. Embedding origins drop the default HTTPS port, which browsers omit from message origins. The connection form no longer carries the embedding hosts, so saving it cannot restore a host removed meanwhile.
…ign-in # Conflicts: # apps/control-plane/src/lib/server/app-sign-in-installed.ts # packages/auth-proxy/src/configuration.ts # packages/auth-proxy/src/worker.test.ts
| const embedding = | ||
| next.embeddingOrigins ?? | ||
| (await readOrganizationSettings(database, organizationId)).embeddingOrigins; | ||
|
|
||
| if (embedding.length && next.sso?.appIdentityType !== "entra") |
There was a problem hiding this comment.
Older settings cannot remove SSO. After embedding hosts are saved, applying an older settings file with
sso: null and directory: null fails here. The omitted embeddingOrigins becomes the saved nonempty list, which is then rejected because next.sso is null. This blocks an existing API/CLI removal request instead of clearing the hosts as the UI does. Clear the hosts when SSO is removed, while preserving omitted lists for Entra updates.
| const save = async (next: string[]) => { | ||
| await writer.save(() => | ||
| ssoInput({ ...ssoDraft(view, organizationId), embeddingOrigins: next }, view), | ||
| ); |
There was a problem hiding this comment.
Host edits undo connection saves. The host buttons stay enabled while the connection form saves. This call copies the full
sso from the still-old view, so a host change sent during that save can run second and restore the old connection settings. A client and secret rotation can then leave sign-in broken. Save hosts without resending the connection, or block host changes until the connection save and refresh finish.
Problem
Organizations want to show published apps inside pages their colleagues already use, such as a Microsoft Teams tab or a company portal. Today an app cannot be framed by another site, and company sign-in does not work in a frame:
frame-ancestors 'self'.SameSite=Lax, so a cross-site frame never sends it.Changes
Settings. Organizations list the page origins that may embed their apps (
embeddingOrigins, HTTPS origins with optional*.subdomain wildcard). This works through the settings UI (new Embedded apps section for Entra connections) and the existing settings API and CLI export/apply. An input that omits the field keeps the saved list, so older settings files do not clear it. The list is published with the app sign-in configuration only for Entra app identity, and removing SSO clears it.Frame ancestors. The auth proxy passes the organization's list to the runtime, which adds it to each app response's
frame-ancestors. App code cannot change it.Embedded sign-in. A framed HTML navigation without a session (
Sec-Fetch-Dest: iframe) goes to/oauth2/ORG/embeddedon the auth host instead of the provider:widefleet:host-token-request) and accepts the answer only from a configured origin. Tokens are exchanged with the auth host only, never with the app frame.oid), and app access rules apply unchanged.HttpOnly; Secure; SameSite=None; Partitionedsession cookie that expires with the host token. The cookie exists only under the embedding top-level site and holds no refresh credential. After expiry, the next framed navigation asks the host again, so access is rechecked with every new token.Sign-out also clears the embedded session.
docs/architecture.mdrecords the boundary.Screens
Settings and the embedded sign-in page with synthetic fixtures, rendered from the merge base (
4dbf4aa0) and from this branch at 1280 and 390 px.Company sign-in settings
Before, the page has no embedding section. After, Entra connections show Embedded apps below the email domains, and the removal text mentions embedding hosts.
Embedding hosts
A saved host, and the Add host dialog rejecting an HTTP origin.
Embedded sign-in page (new)
Shown in a frame of
https://portal.example.test: waiting for the host, the host reporting that it has no token, and missing admin consent.Not shown: the 15-second timeout and the server-error state, which use the same layout as "No host token" with the generic message.
Verification
pnpm check, fullpnpm exec vitest runagainst the local test services (1101 passed), and the self-hosted SSO Playwright spec.RUN_EDGE_TESTS=1) embeds an app from a cross-site page that answers the token request. It checks the forwarded identity and the cookie's partition key, and that a page on an unlisted site gets no app. WithoutPartitionedthe test fails.Not verified here: a real Teams client, and Safari. Safari supports partitioned cookies from 26.2. Playwright's Linux WebKit does not implement cookie partitions, so it cannot test this flow.
Documentation: #223 (draft, blocked on the release that contains this change).
Do not merge until host changes cannot overwrite connection saves and older settings files can remove SSO.
Findings
Summary
Adds host-token sign-in for Entra apps embedded on approved sites, with separate cookies that expire with the host token.
A host change can overwrite a connection save that is still running.
Diagram
sequenceDiagram participant Host as Approved host page participant Page as Auth-host frame participant Proxy as Auth proxy participant Entra as Entra and Graph participant App as App runtime Page->>Host: Request host token Host->>Page: Return token Page->>Proxy: Submit token on auth host Proxy->>Entra: Verify token and fetch user and groups Proxy-->>Page: Set partitioned session cookie Page->>Proxy: Confirm cookie was kept Page->>Proxy: Navigate back to app Proxy->>Proxy: Check session and app access Proxy->>App: Forward identity, without sign-in cookies App-->>Page: App response with approved frame hostsReviews (9) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile