Repository navigation
feat: edit an OAuth2 app's redirect URIs as an ordered list - #29603
Merged
Merged
Conversation
Editing an app's callback added a new accepted URI without removing the old one, and the admin API only showed the callback (PLAT-619, SEC-870). - Backfill every row so the callback is the first redirect URI. The migration handles empty, missing, and out-of-order lists and is safe to rerun. The callback column is kept, marked deprecated. - Read redirect URIs from the list only. A callback that is not in the list is no longer accepted. - Write both columns together from one shared function. A callback-only update now replaces the previous primary and keeps the rest. - Validate every entry the same way as the callback. - Cap the list at 32 entries of 2048 bytes each, including at registration. No existing request or response changes shape.
… app update - Admin updates re-checked the whole stored list against the new caps. - Apps registered before the caps with over 32 URIs, or a URI over 2048 bytes, could not be edited at all. - Only URIs the request adds are checked now. The count cap applies only when the list grows.
… redirect URIs - An old replica writes only callback_url on an admin update. - New replicas read redirect_uris first, so that edit is not seen until the app is saved again. - Drain old replicas before upgrading to avoid it.
…de window - redirect_uris is now the source of truth, with the primary first. - During a rolling upgrade, a callback edit on an old replica is not seen by new replicas until the app is saved again. - An app may register at most 32 redirect URIs of at most 2048 bytes each. Older apps beyond that keep working.
- Covers all four documented input shapes, plus dedup and callback ordering. - The doc comment notes that the list-with-callback and neither shapes get their caller when the admin API gains redirect_uris in the next PR.
…he callback field - A failure on the request callback_url now says "callback URL ..." with no list index. - List entries keep the indexed wording for registration callers.
…lidation - The shape check now rejects fragments, so admin and registration store the same rules. - Rename ValidateOAuth2CallbackURL to ValidateOAuth2RedirectURIShape and the local validator to validateAppRedirectURIFields. - The column comment says "first entry of redirect_uris" instead of a 1-based index. - RegisteredRedirectURIs documents that it is never empty. - Test that registration stores a deduplicated list. Use plain numbered test URIs.
- ValidateRedirectURI now rejects hostless http(s) and opaque URIs for every client type. - Move the shared rules into a helper so both paths use one copy. - Test that ValidateRedirectURI rejects everything the shape check rejects.
…thub.com/coder/coder into plat-619-1-redirect-uris-source-of-truth
…upgrade - The doc bullet and migration comment said the edit was "not visible". - They now say it is silently discarded and the app keeps accepting the previous redirect URIs until saved again.
- Drop the forward reference to the next PR from the resolveRedirectURIs doc. - Let the public client rejection message stand on its own instead of repeating "public client".
- Remove the oauth2_callback_url struct tag. It ran the shape check first and failed with a generic tag message. - The handler already runs the same check and names the reason against callback_url. - Test that a callback with a fragment reports that reason.
…pdate itself - The RFC 7592 update path validated the full resent list with no stored context, so a legacy over-cap client could not save any change. - It now skips redirect URIs the client already has and applies the count cap only when the list grew, matching the admin path. - Create still enforces the caps on every entry. - Remove the duplicated ValidateRedirectURIScheme doc comment.
…thub.com/coder/coder into plat-619-1-redirect-uris-source-of-truth
- Legacy clients may store duplicates, and the stored baseline is deduplicated. - Resending the list as returned no longer reads as growth.
…rowth" This reverts commit 7ba41c6.
…I caps update itself" This reverts commit 1e38088.
… URIs on app update" This reverts commit 718b1f9.
- Stored redirect URIs are checked again on every update, with no exception for apps that predate the caps. - An app over the limits must be deleted and created or registered again. - Remove the duplicated ValidateRedirectURIScheme doc comment again.
…hority - Registration accepted the bare scheme:value form before this change. - Add test cases for the three private-use forms.
- Rename ValidateOAuth2RedirectURIShape to ValidateRedirectURIShape to match its siblings. - Scheme errors no longer start with "redirect URI", since every caller adds its own subject.
…callback_url - Add redirect_uris to the app response and the create/update requests. - callback_url still works but is deprecated; it equals the first entry. - Fix a bug where an empty redirect_uris list was silently ignored instead of rejected. - Update fixtures, tests, and docs for the new field.
CI failed because redirect_uris is required on the generated type but missing from the entities.ts mocks.
jakehwll
reviewed
Sep 22, 2026
jakehwll
reviewed
Sep 22, 2026
jakehwll
reviewed
Sep 22, 2026
jakehwll
reviewed
Sep 22, 2026
BobbyHo
added a commit
that referenced
this pull request
Sep 22, 2026
…callback_url (#29502) - Add `redirect_uris` to admin OAuth2 app responses and create/update requests. - Deprecate `callback_url` while preserving compatibility; it maps to the first redirect URI. - Reject empty `redirect_uris` lists instead of silently ignoring them. - Update fixtures, tests, and docs. Part of PLAT-619. Builds on #29440; admin UI support follows in #29603.
Main squashed the API PR this branch was stacked on and then fixed the stored invalid callback case in the old single-field form. Take main's Go tests, migration numbering, and docs wording, keep the redirect URI list form, and port the stored invalid value fix to the list: mark the field touched on load when the stored list fails validation so its errors show right away. Also correct the style guide coverage table so the style-claims hook passes; main is currently red on that check.
…eck redirect URI uniqueness once over the list The duplicate check ran on each row and had to find its own index by matching a regex against the Yup path, with the sibling list typed as unknown. Move it onto the array, where the value is typed as a list of strings, and report each duplicate row through createError. Every row that repeats an earlier one is now flagged in the same pass instead of one per validation.
Contributor
Documentation CheckUpdates Needed
Automated review via Coder Agents |
…ss the OAuth2 client type to the app form The form read the client type from the optional app prop, so a missing app silently meant confidential rules. Take the type as its own required prop instead. The edit page passes the loaded app's type and the create page passes confidential, since public clients only come from dynamic client registration.
…): move RedirectURIsField under components Keep page views and forms at the top of the page folder and the building blocks they use under components, matching other page folders.
…it an unchanged redirect URI list from app updates The form sent the loaded list on every update, so a rename made after another admin removed a URI restored that URI. Send redirect_uris only when the ordered list differs from the loaded one, as the form already does for scope. Creates and list edits still send the full list. A create must always carry the list while an update may leave it out, so the app and onSubmit props are now a union of a create variant that submits the POST request type and an edit variant that submits the PUT request type.
…im a redirect URI before validating it The old callback field trimmed before its tests ran, but the per-row schema did not, so a pasted URL with a leading space failed the anchored http(s) check and disabled save even though submit trims it. Restore the trim and cover padded https and loopback http values, since the existing padded cases only used custom schemes.
…ed the scopes query in the new edit stories The form always loads the scope catalog, so without the fixture these two stories made a real request that the Storybook test server refused and showed an unrelated scopes error next to the redirect URI state they are meant to capture.
…over the redirect URI byte limit at its boundary The byte-limit table only exercised the app name. Add a table for the redirect URI: a multibyte URI of exactly the limit submits unchanged and one byte over does not, while both stay below the limit by string length, so the test fails if the check ever counts characters.
… of index The admin endpoint reported a bad entry as "at index N" counting from zero, while the web UI labels rows from one, so an admin had to translate the number. Count from one and cover a fragment in a confidential app's second entry, which passes the form's check and only fails on the server.
jakehwll
reviewed
Sep 23, 2026
jakehwll
approved these changes
Sep 23, 2026
jakehwll
left a comment
Collaborator
There was a problem hiding this comment.
one nit on how props are destructured, otherwise frontend LGTM 🥳
…): destructure form props in the parameter list OAuth2AppForm took a single props argument and pulled fields out of it on the next line. It did this because the props type is a discriminated union on app and onSubmit, and destructuring them separately would stop a check on app from narrowing onSubmit. Destructure the plain props in the parameter list and collect app and onSubmit into a rest object. TypeScript keeps the union through object rest, so the submit handler still narrows the same way.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Third of three in PLAT-619. #29440 made
redirect_uristhe source of truth in the database. #29502 added it to the admin API. This PR replaces the single callback URL field in the web UI with an editable list.redirect_urison the admin API. Markcallback_urldeprecated.Stack: #29440, then #29502 (this branch is based on it), then this PR.
Sample Screen Captures:

Manual Tests
Scenario summary, all 24
.localhost, custom scheme, OOB URN,javascript:, malformed)redirect_urisorder exactly, first row stays "Default callback"+1(singular aria-label) at 2,+N(plural) at 3+redirect_uris.slice(1).join("\n").localhostrefused (unlike a confidential app); plain loopback still accepted#fragmentandmailto:refusedScenario 7 (byte-length validation) was not run this pass. Two accessibility
issues were found and are pre-existing, not introduced by this PR — see the
notes under scenarios 19-20 and the summary below the table.
Setup and verification commands
Run against the dev server through a
coder port-forward ... --tcp 3000:3000 --tcp 8080:8080tunnel. The dashboard (:8080) is where everyscenario below is actually driven from a browser;
curl/sshare used onlyfor the setup and verification calls shown in each scenario, reading the
session token from inside the workspace:
1. Prerequisites
Dev server built from the PR branch with
CODER_OAUTH2_PROVIDER_ENABLE=true;buildinfoconfirmedoauth2_provider:true. Dashboard loaded with an emptyapps table (fresh database).
Seeded one DCR app for section 4, noting the DCR flag's starting value
first so it can be restored in cleanup:
Applications table then showed one row,
plat619-form-dcr, callback columnhttp://localhost:9876/callbackplus a+1badge — an early look atscenario 16 already working.
2-9. Create form
Default state (
/deployment/oauth2-provider/apps/add): one row labeled"Default callback", empty, required; description text is the
confidential-client copy; "Create application" disabled.
Add/remove: filling row 1 and clicking "Add redirect URI" twice produced
"Redirect URI 2" and "Redirect URI 3"; removing the old row 2 renumbered the
remaining row to "Redirect URI 2" and left row 1's value untouched.
Removing the last (only) row: list becomes empty, "At least one redirect
URI is required." shown, "Create application" stays disabled.
32-row cap: "Add redirect URI" disables at exactly 32 rows. No list-level
cap message appears merely for being at the cap (the two red messages
visible are the ordinary per-row "Please enter a valid redirect URI." on
the two empty rows added last, unrelated to the cap) — there's no UI path
to a 33rd row to exercise the list-level max-count message.
Shape validation (confidential client), one row at a time:
Duplicate URI: entering the same valid URI in two rows flags only the
second occurrence ("This redirect URI is already used by another row.");
the first occurrence shows no error and the value isn't silently dropped.
Submit: naming the app and providing a single valid URI, then clicking
"Create application", navigated to
/deployment/oauth2-provider/apps/<id>?created=truewith the "Your OAuth2application has been created..." banner and a client ID. The success toast
itself wasn't caught in a screenshot (auto-dismissed before the
post-navigation capture); the navigation and banner outcome it precedes
was confirmed directly, so this wasn't re-tested.
Byte-length validation (a 2049+ byte URI on one row) was not run this
pass.
10-14. Edit form
Pre-population and ordering: an app was given three
redirect_urisdirectlyvia the API (bypassing the UI, since the app created above had only one
URI and wouldn't exercise ordering) —
Reloading the edit page showed all three rows in that exact order, first
row still labeled "Default callback".
Update-disabled-until-dirty: on a clean load, "Update application" is
disabled. Appending a character to a row's value enables it; reverting the
character (without submitting) leaves nothing persisted.
Removing the last row on a populated edit form: removing all three rows one
at a time reproduces the create form's behavior exactly — "At least one
redirect URI is required." shown, Update disabled. Not submitted; page
reloaded afterward to discard.
Submit persists the list and order: reduced to one row, added a second via
"Add redirect URI" (confirming no drag/reorder control exists on any row —
just a text input and an "×" remove button), then "Update application".
Verified via the API, the edit-page reload, and the applications table, all
three agree on the persisted order and the resulting
+1badge. Thesuccess toast wasn't caught in a screenshot here either, for the same
reason as the create-form submit above; persistence was confirmed directly
against the API instead of relying on the toast.
Unsaved-changes prompt: editing a field then clicking "Back to
applications" shows the "Unsaved changes" dialog ("Your updates haven't
been saved. Leave anyway?"). Cancel stays on the page with the edit intact;
Confirm navigates away and discards it (confirmed via reload). Repeating
with no edits made navigates away with no dialog.
15-16. Applications table badge
Needed one app at each of 1, 2, and 3+ URIs to exercise every branch. Set
up via the API (one fresh 1-URI app; bumped an existing app to 3 URIs),
then read the actual
aria-label/titleattributes from the DOM ratherthan relying on the visual badge alone:
Both singular/plural wording and the tooltip's per-line URI list matched
redirect_uris.slice(1).join("\n")exactly for both multi-URI apps.Hovering the badge itself didn't render into a screenshot — it's a native
browser
title-attribute tooltip (OS/browser-chrome popup), which doesn'trasterize into an automated capture even on a real hover; the DOM check
above is the reliable verification for this case.
17-18. Public-client (DCR) app in the edit form
On the DCR app's edit page, the redirect-URIs description read exactly:
"This app has no client secret, so http is limited to a loopback address;
https, a custom scheme, and the out-of-band URN are also accepted."
Note: the PR description for
mailto:/tel:/sms:suggested apublic-client-only code branch is what blocks those schemes. Tried the same
mailto:value against a confidential app as a follow-up, and it wasrefused there too, with the identical message — so whatever's actually
blocking
mailto:in the UI doesn't appear to be specific to thepublic-client branch. Not treating this as a bug (the confidential-client
refusal likely comes from a different, more general check), just noting
that the public-client-only framing may not be distinguishing anything
observable in the UI.
19-21. Keyboard and accessibility
Tabbing from the Name field reached, in order: the Default callback row,
its Remove button, Redirect URI 2, its Remove button, Redirect URI 3, its
Remove button, then "Add redirect URI" — every redirect-URI-specific
control reachable in a sensible order, no trap among them. Enter on "Add
redirect URI" added a row; Shift+Tab to its Remove button, then Space,
removed it correctly.
Two accessibility notes, both pre-existing and unrelated to this PR's
redirect-URI logic:
document.activeElementbecomes<body>immediately (confirmed not transient). In practice the next Tabpress still lands on a sensible control ("Add redirect URI"), thanks to
Chromium's default focus-position preservation after removing the
focused element — not explicit focus management in the form — so it
isn't a dead end, but a screen reader would announce nothing useful at
the exact moment of removal.
application" lands on the
<em-emoji-picker>custom element used by the(out-of-scope, pre-existing) Icon field, and neither Tab, Shift+Tab, nor
Escape can move focus off it — a genuine two-directional keyboard trap
that blocks a keyboard-only user from ever reaching "Allowed scopes" or
"Update"/"Create" from the redirect-URI fields on either form. Confirmed
it's specific to arriving at the picker via Tab (clicking directly into
a later field and tabbing from there works normally), so it isn't a
page-wide issue — just this one field.
Accessible names: removing the first row of a 3-row app renumbered the two
remaining Remove buttons to "Remove redirect URI 1" and "2" (not the stale
"2"/"3" they'd have carried if keyed on a memoized id) — confirming the
name is keyed on the row's current position. The badge's accessible name
was already verified in scenarios 15-16.
22. Icon field regression check
Not part of this PR's redirect-URI change, but spot-checked since it's easy
to verify here. Set an icon on an app via the API, confirmed it appeared in
the edit form's Icon field, cleared the field, and saved:
Icon cleared, not left at its old value — the update request sends the
empty icon rather than omitting it. Applications table also showed the
fallback letter-avatar afterward, not the emoji.
23-24. Cleanup
Deleted every app created during this run (the create-form submission, the
badge-count scratch app, and the seeded DCR app) through each edit page's
"Delete" button and its confirm dialog. Applications table returned to "No
OAuth2 applications configured," matching the pre-run empty state.
Note: the delete-confirmation field showed each app's name pre-filled
on dialog open (resembling browser autofill), but the "Delete" button
stayed disabled against that pre-filled text — clicking it would have done
nothing. Retyping the name via keyboard was required each time before
"Delete" enabled. Not a redirect-URI issue, but worth flagging: a user
could reasonably assume the pre-filled text already satisfies the
confirmation and be confused when Delete stays disabled.
DCR flag restored to its pre-run value (
false), confirmed via the APIbefore and after the restore.