Files
coder/coderd/httpapi
Atif Ali f79a36469e fix: relax OAuth2 app form validation for names and callback URLs (#29333)
## Problem

The OAuth2 application settings form rejects application names with
spaces and callbacks using native application schemes. A VS Code
extension client registered through DCR exposed this: `VS Code Coder
Extension` and `vscode://coder.coder-remote/oauth/callback` were already
stored, but the admin form prevented editing them.

## Fix

- Allow application names with spaces and punctuation, limited to 64
UTF-8 bytes on both client and server.
- Allow native callback schemes while rejecting dangerous schemes,
unsupported URNs, opaque callbacks such as `localhost:3000`, and empty
targets such as `vscode:`. HTTP(S) callbacks still require a host.
- Reuse the public-client registration policy when admins update public
clients, so `mailto`, `tel`, `sms`, external HTTP, and fragments remain
rejected.
- Trim surrounding whitespace from names and callbacks when submitting,
without stripping spaces while typing.
- Update the admin API request validators too, so accepted form values
can be saved.

The server remains authoritative for URL parsing. Public-client edits
reuse the existing DCR redirect validator using the stored client type;
confidential admin-created applications retain their existing HTTP
policy. Native host/path callbacks and the supported OOB URN remain
accepted.

## Validation

- Vitest component tests assert create/edit submission payloads,
whitespace normalization, Unicode byte limits, and rejection of unsafe
or malformed callbacks.
- Storybook stories cover accepted native-client values and invalid
callback states.
- Go tests cover name boundaries and accepted/rejected callback values
through both admin create and update requests.
- `make pre-commit` and targeted tests run before pushing; CI checked on
each revision.

<details>
<summary>Implementation decisions</summary>

- Replace the shared slug validator only for OAuth2 application names;
leave user, workspace, and template names unchanged.
- Share the backend's 64-byte name limit with the frontend through the
generated `OAuth2AppNameMaxBytes` constant.
- Reuse `codersdk.ValidateRedirectURIScheme` for common admin callback
validation. Public-client updates additionally call
`codersdk.ValidateRedirectURIs`; confidential admin HTTP behavior is
preserved.
- Normalize name and callback whitespace in the submitted payload rather
than on each keystroke.
- Keep behavior assertions in Vitest and use Storybook for visual
states.

</details>

Closes ENG-3342

> 🤖 This PR was created with the help of Coder Agents, and needs a human
review. 🧑💻
2026-09-16 21:06:31 +05:00
..
…
…