Skip to content

feat(embedded): add PKCE (S256) to the embedded authorize flow - #1141

Open
pmathew92 wants to merge 1 commit into
v5_developmentfrom
feat/embedded_pkce
Open

pmathew92 wants to merge 1 commit into
v5_developmentfrom
feat/embedded_pkce

Conversation

@pmathew92

@pmathew92 pmathew92 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Changes

Adds PKCE to every embedded /e/authorize flow. The server accepts code_challenge and code_challenge_method on the first /e/authorize call, binds the authorization code to the challenge, and then requires the matching code_verifier at /oauth/token. Clients that enforce PKCE, and public clients on tenants with the PKCE-required setting, are rejected without it, so the SDK now always sends it.

How it works

  • authorize() creates a new code verifier for each flow, sends its code_challenge with code_challenge_method: "S256", and creates the flow state with the verifier.
  • Each continuation only updates the auth_session in that state, so the verifier is kept for the whole flow.
  • Final steps read the verifier when they are built and send it as code_verifier with the token exchange. This matters because the state is cleared as soon as the server issues the code, before the exchange runs.
  • If the challenge can't be created (SHA-256 unavailable), authorize() fails locally without sending a request. It never falls back to a flow without PKCE.
  • The verifier is never exposed to the app or logged, and there is no option to turn PKCE off.

Classes and methods

  • AlgorithmHelper moves from provider/AlgorithmHelper.java to util/AlgorithmHelper.kt as an internal open class, so the web-auth and embedded flows share one implementation. Behavior is unchanged. PKCE.java and its tests only change their import.
  • EmbeddedAuthState now holds codeVerifier and a nullable authSession. Its toString hides both.
  • EmbeddedAuthClient gains an internal constructor that takes an AlgorithmHelper, used by tests. The public EmbeddedAuthClient(auth0) constructor is unchanged.
  • No public API changes. examples/embedded-auth/authorize.md has a short note that PKCE is added automatically.

Testing

  • This change adds unit test coverage

  • This change adds integration test coverage

  • This change has been tested on the latest version of the platform/language or why not

Checklist

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 709569ab-4935-4fd1-9903-e7b183287132

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@pmathew92 pmathew92 changed the title feat(embedded): add PKCE (S256) to the embedded authorize flow [non-main] feat(embedded): add PKCE (S256) to the embedded authorize flow Nov 16, 2026
/** A random, base64url-encoded code verifier made of 32 random bytes. */
open fun generateCodeVerifier(): String {
val code = ByteArray(32)
SecureRandom().nextBytes(code)
@pmathew92
pmathew92 marked this pull request as ready for review November 16, 2026 05:58
@pmathew92
pmathew92 requested a review from a team as a code owner November 16, 2026 05:58

This branch has not been deployed

No deployments
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