Skip to content

Recommend PKCE and deprecate the client secret - #974

Merged
kevincador merged 3 commits into
masterfrom
feat/pkce
Oct 2, 2026
Merged

kevincador merged 3 commits into
masterfrom
feat/pkce

Conversation

@kevincador

@kevincador kevincador commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes PKCE the recommended way to sign users in to Trakt, and starts phasing out the Client Secret for anything but server-to-server calls. With PKCE as the default, a copied Client ID can no longer be turned into tokens.

API reference (@trakt/api)

  • Document the PKCE parameters: code_challenge and code_challenge_method on authorize, and code_verifier on token.
  • client_secret is now optional and marked deprecated on every /oauth body (token, refresh, device token, revoke), from one shared schema.
  • Authorization Code Flow endpoint descriptions point to the PKCE guide, and client_secret is removed from request tables.

Developer portal

  • New guide at /docs/pkce: why PKCE, the authorization code and device code flows, and redirect URI rules. Linked from Authentication and Create an App.
  • App page: PKCE recommendation next to the Client Secret, which is now labelled deprecated. When the API stops returning a secret, the page shows a "not issued" placeholder instead of an empty value.
  • App page and app form: a prominent warning when a redirect URI is not a public https:// address (custom schemes, http://, localhost, out-of-band). Mobile apps are pointed to Universal Links and verified App Links. It warns but does not block saving.
  • Request body samples leave out deprecated fields, so client_secret no longer appears in the /oauth samples.
  • Fix: the apps page no longer returns a 500 in local dev when PUBLIC_GITHUB_CLIENT_ID is not set. Connect GitHub is disabled with a note instead. The ID is now read from the dynamic public env, which the static build writes to /_app/env.js. @vladjerca feel free to revert that commit, I just needed that to test locally 👨‍🔬

Notes for reviewers

  • Existing apps that use custom-scheme or localhost redirects will start seeing the warning. This is intended.
  • The @trakt/api change needs a version tag to publish.

Test plan

  • deno task check, deno task test (325 passing), deno task build, and both format checks in projects/developer
  • deno fmt --check, deno lint, and deno task publish:check in projects/api
  • deno task openapi:validate
  • /docs/pkce renders and shows in the sidebar
  • The postOauthToken sample body has no client_secret, and the note renders on the /oauth endpoints
  • /apps loads without PUBLIC_GITHUB_CLIENT_ID
  • App detail page with and without a secret, and with an insecure redirect URI (needs a signed-in account with GitHub linked)
  • App form shows the warning live while typing an insecure redirect URI

Local testing screenshots

Screenshot 2026-10-02 at 09 11 44 Screenshot 2026-10-02 at 09 11 31

@kevincador
kevincador requested a review from vladjerca October 2, 2026 07:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T07:56:41.829248Z d785eb7 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2c8322e5a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread projects/developer/src/lib/features/apps/PkceNotice.svelte Outdated
Comment thread projects/api/src/contracts/oauth/schema/request/codeRequestSchema.ts Outdated
Comment thread projects/developer/src/lib/features/apps/unsafeRedirectUris.ts Outdated
@kevincador

Copy link
Copy Markdown
Contributor Author

Addressed all three Codex points, each folded into its origin commit:

  • P1 bare element selectors in the notices: child classes, in a9ecedb.
  • P2 code_challenge_method: restricted to the S256 literal, in 8b40e92.
  • P2 private-network redirect hosts: private and link-local IPv4/IPv6 and .local now flagged, in a9ecedb.

Pushed as d785eb7. Portal check, 335 tests, and build green; api lint and publish dry run green; OpenAPI validates.

@kevincador

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d785eb7b64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread projects/api/src/contracts/oauth/schema/request/codeRequestSchema.ts Outdated

@vladjerca vladjerca left a comment •

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.

Posted in error.

@vladjerca
vladjerca dismissed their stale review October 2, 2026 10:38

Posted in error.

PKCE is now the recommended way to sign users in, and the Client Secret
is deprecated for anything but server-to-server calls.

- Add code_challenge and code_challenge_method to the authorize and
  device code requests, and code_verifier to the token and device token
  requests.
- Make client_secret optional and deprecated on every /oauth body
  (token, refresh, device token, revoke), from one shared schema.
- Add a note to every /oauth endpoint description pointing to the PKCE
  guide, and drop client_secret from the request tables.
Enforcing PKCE as the default makes a copied Client ID useless, so the
portal now steers developers to it.

- Add a PKCE guide at /docs/pkce, covering both the authorization code
  and device code flows, and link it from Authentication and Create an
  App.
- Show a PKCE recommendation next to the Client Secret on the app page
  and mark the secret deprecated. When the API stops returning a
  secret, show a placeholder instead of an empty value.
- Warn on the app page and in the app form when a redirect URI is not a
  public https:// address (custom schemes, http, localhost, out-of-band).
- Leave deprecated fields out of generated request body samples, so
  client_secret no longer appears in the /oauth samples.
A missing PUBLIC_GITHUB_CLIENT_ID made the static env import fail, so
the apps page returned a 500 in local dev. Read it from the dynamic
public env instead, and disable the Connect GitHub buttons with a note
when it is not set.

@vladjerca vladjerca left a comment

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.

Validated the corrected OAuth contract and developer documentation: OpenAPI validation, API lint and publish dry run, plus developer formatting, type-check, build, and 335 tests all pass. The public documentation now matches the supported flows.

Reset your local branch before pushing again.

@kevincador
kevincador merged commit 4d57274 into master Oct 2, 2026
5 checks passed
@kevincador
kevincador deleted the feat/pkce branch October 2, 2026 11:35
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.

2 participants