Repository navigation
Show profile pictures in apps - #409
Merged
Merged
Conversation
tnkuehne
force-pushed
the
app-profile-pictures
branch
from
November 25, 2026 18:08
b7f74c3 to
ce2d827
Compare
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | bfd0447 | Nov 25 2026, 08:10 PM |
tnkuehne
force-pushed
the
app-profile-pictures
branch
2 times, most recently
from
November 25, 2026 20:09
2e63741 to
bfd0447
Compare
Apps could not show people's pictures: the app CSP allows only the app's
own origin, and people who use only apps may never sign in to the control
plane. The app sign-in proxy now copies the picture at sign-in and
renewal and serves it itself:
- Entra photos come from Graph; Google and OIDC pictures from the ID
token's picture URL, asked only at the provider's origin or Google's
picture host. Widefleet's own app sign-in names the control plane's
copy, which accepts that sign-in's access token for its own picture.
- Copies live in a new USER_PICTURES KV namespace, keyed by organization,
issuer and subject. Each expires 30 days after its last write, and the
provider is asked again at most once a day.
- /oauth2/pictures/{subject} on app origins serves them after the usual
session and access checks, to everyone who may use the app.
- Apps receive x-auth-request-picture with the path and version; both
starters expose it as user.picture.
Hosted provisioning creates the namespace and binds it to the runtime;
the self-hosted agent binds widefleet-user-pictures.
Missing and unreadable pictures now record when the provider was asked, so the daily limit applies to them too, and a provider that names no picture removes the copy. Embedded sign-in copies the Graph photo with the host token's access. The picture route moves out of the (auth) pages, which redirect requests without a browser session, so the app proxy's access token reaches it. The provisioning tests cover the new namespace.
Parallel renewals of one session asked the provider and wrote the same KV key at once. A write over KV's per-key limit failed the refresh and saved the session without its picture. Refreshes in one isolate now share their work, and a failed write keeps the stored version.
App sign-in through Google Workspace never named a picture: Google leaves it out of Workspace ID tokens. The proxy now reads the user info when the ID token names none, Google's for Workspace and the discovered endpoint for other OIDC providers, before it reports that there is no picture.
A failed discovery of the user info endpoint fell back to the ID token and removed the copy. It now keeps it, like a failed user info request.
tnkuehne
force-pushed
the
app-profile-pictures
branch
from
November 25, 2026 20:17
bfd0447 to
7ddc76b
Compare
tnkuehne
added a commit
that referenced
this pull request
Nov 25, 2026
…ints (#414) Hosted installations never copied a profile picture after #407 and #409. Every sign-in cleared the provider URL from sign-up and left people with initials. ## Cause The picture fetches in `packages/auth-proxy/src/picture.ts` passed `redirect: "error"`. Cloudflare Workers accepts only `"follow"` and `"manual"` and throws `TypeError: Invalid redirect value` before sending. The helpers caught it and reported an unreadable picture, so image downloads, user info requests and the app proxy's discovery never left the Worker. Node accepts `"error"`, so the existing tests passed. ## Changes - **Redirect mode.** The three picture fetches (image, user info, discovery) use `redirect: "manual"`. A redirect is a non-2xx response, so it still reads as unreadable and its target is never requested. - **Missing user info endpoint.** A company connection saved without `userInfoEndpoint` treated an ID token without `picture` as no picture and removed the copy. This happens, for example, when the provider adds the endpoint after registration: same-issuer saves keep the three sign-in endpoints and skip discovery. - `prepareCompanyOidc` takes `{ discoverMissingUserInfo: true }`, which also discovers when the user info endpoint is missing. Saved endpoints keep precedence and every endpoint gets the same checks as at sign-in. - Only the picture lookup passes the option, and a failed discovery keeps the copy. ## Tests - `packages/auth-proxy/src/picture.worker.test.ts` runs the shared helpers in workerd through Miniflare and records the outbound requests. It covers OIDC through discovery and user info, the Microsoft Graph photo, and redirects from user info and from a picture URL, whose targets receive no request. With `"error"` all three tests fail; with `"manual"` they pass. - `company-sso-plugin.integration.test.ts` adds a `partial` connection. It is registered while discovery advertises no user info endpoint, then the endpoint appears and a returning sign-in without an ID-token picture copies the user info picture. A failed discovery keeps the copy, and discovery that still omits the endpoint removes it. Without the source changes the case fails. The `registered` connection still refreshes from its saved endpoint without discovery. - `picture.test.ts` checks the redirect mode and that a 302 reads as unreadable. - Type checks, Oxlint and Oxfmt pass. The `packages` and `apps/control-plane` suites pass except `runtime-errors.integration.test.ts`, which needs a built server and fails on `main` the same way locally. <!-- greptile_comment --> <!-- greptile_summary --> <h2><ruby><rp>Confidence Score: 5/5 · The PR appears safe to merge.</rp></ruby><a href="https://app.greptile.com/api/retrigger?id=119991947&sig=8ae276a82c3b297d32f0a6b03f0d34e2a4d6434c9fe714f3a305a18a13f4d627"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F414&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2> <!-- greptile-impact-verdict --> The PR appears safe to merge. <details open><summary><h3>Summary</h3></summary> Fixes picture downloads on Cloudflare Workers and finds missing company user info endpoints during picture lookup. - Provider pictures can now be fetched from Workers without following redirects. - Company sign-ins can find user-info endpoints added after connection setup. No actionable issues were found. Tests were inspected but not run during this review. </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (1) · Last reviewed commit: ["Copy profile pictures on Workers and dis..."](c5a4aad) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apps now get each signed-in person's profile picture from their own address. The app sign-in proxy copies the picture when someone signs in to an app. It serves it at
/oauth2/pictures/{subject}on every app origin of the organization and names it in a newx-auth-request-pictureheader.Stacked on #407.
Why
The control plane keeps its own copy of each person's picture (#407), but apps cannot use it:
The proxy already holds the company sign-in's tokens and serves every app origin, so it copies and serves the picture itself. It never asks the control plane.
Changes
getUserInfoin the auth proxy reads the picture with the sharedproviderPicture:/me/photos/120x120/$value. The proxy already requestsUser.Read.picture, or the user info when the ID token names none (Google's endpoint for Workspace, whose ID tokens never carrypicture; the discovered endpoint for OIDC). Only the provider's own origin, with the access token, or Google's account picture host is asked for the picture.pictureclaim from Copy profile pictures from every sign-in provider #407. The proxy fetches it from the installation with the sign-in's access token./users/{id}/pictureaccepts that token for the person's own picture only (tokenViewer). The route moves out of the(auth)pages, which would send a request without a browser session to sign-in.USER_PICTURES, bound to the app runtime./oauth2/pictures/{subject}on app origins.ETag,private, no-cache,nosniff, a sandboxing CSP andsame-originresource policy. The request never reaches app code.x-auth-request-picture: /oauth2/pictures/{subject}?v={version}when the person has one, without a KV read per request.locals.user/context.usergainpicture(path ornull). Local development usesnull.{installation}-user-picturesand binds it to the runtime.widefleet-user-pictures(runtime.rs,execution.rs).wrangler.jsoncdeclares the binding.Documentation
Draft docs PR #411 describes
user.picturefor app creators and theUser.Readpermission.Verification
edge/auth-proxy-sessions.test.ts, run for OIDC and for Entra:x-auth-request-picture.304for its ETag; without a session it answers401.edge/auth-proxy-google.test.ts: a Workspace app sign-in copies the picture named in Google's user info and serves it on the app's origin.organization-sso.integration.test.ts: the access token of Widefleet's app sign-in reads its own picture throughtokenViewer, not another person's; an invalid token reads nothing.packages/auth-proxy/src/picture.test.ts: the shared fetch rules (from Copy profile pictures from every sign-in provider #407) and the store, which asks at most once a day for a picture, no picture or a failure.edge/auth-proxy-embedded.test.ts: embedded sign-in forwards the copied Graph photo.cloudflare/hosted-installation.test.ts: the runtime bindsUSER_PICTURES, the control plane onlyAUTH_CONFIG; provisioning creates and reuses both namespaces.apps/control-planeandpackagespasses exceptruntime-errors.integration.test.ts, which needs a built server and fails onmainlocally.cargois not installed here), so CI checksruntime.rsandexecution.rs. The installed self-hosted runtime with the new namespace is not exercised end to end.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issues remain.Summary
Apps receive profile pictures through their own origin.
The current code addresses all six previous unnumbered findings. No new actionable issues were found.
Diagram
sequenceDiagram participant Provider participant Proxy as App sign-in proxy participant KV as USER_PICTURES participant App participant Browser Provider->>Proxy: Verified identity and access token Proxy->>KV: Read last picture check opt Daily check is due Proxy->>Provider: Request picture Proxy->>KV: Save result and check time end Proxy->>App: Forward identity and picture path Browser->>Proxy: Request picture on app origin Proxy->>Proxy: Check session and app access Proxy->>KV: Read picture Proxy-->>Browser: Picture bytes or 304Reviews (5) · Last reviewed commit: "Keep the app picture when user info disc..." · Reviewed by Greptile