Skip to content

Forward optional nonce on /authorize request#271

Open
partha-uber wants to merge 1 commit into
mainfrom
sirker-authorise-nonce-param
Open

Forward optional nonce on /authorize request#271
partha-uber wants to merge 1 commit into
mainfrom
sirker-authorise-nonce-param

Conversation

@partha-uber
Copy link
Copy Markdown
Contributor

Summary

The Uber auth server requires a nonce query parameter on /authorize when the requested scope includes openid. It echoes the value back as the nonce claim of the issued ID token so the caller's backend can verify it and reject replays. Today the Android SDK has no way for developers to supply one — there's only an INVALID_NONCE error enum on the receiving side.

This adds an optional nonce: String? field on AuthContext. When set, AuthProvider puts it into the optionalQueryParams map it already passes to UniversalSsoLink.execute(), which appends it to the /authorize URL. No signature change to UriConfig.assembleUri(), no behavior change when the caller doesn't set it.

The SDK does not generate, store, or validate the nonce — that responsibility stays with the caller's backend (which already has to maintain a server-wide dedupe set per the partner integration spec).

Files changed

  • core/.../UriConfig.kt — add NONCE_PARAM = "nonce" constant.
  • authentication/.../request/AuthContext.kt — add nonce: String? field with KDoc.
  • authentication/.../internal/AuthProvider.kt — include nonce in getQueryParams() when present.
  • Tests — AuthProviderTest verifies the nonce is forwarded when present and absent when not.

Test plan

  • ./gradlew :authentication:test :core:test — green
  • ./gradlew :authentication:assemble :core:assemble :rides-android:assemble — green
  • ./gradlew spotlessCheck — green
  • Reviewer to confirm spec interpretation: SDK forwards a caller-supplied nonce (does not auto-generate one when openid is in scope).

Revert plan

Straight git revert — no migrations, only an additive optional field. Existing callers compile unchanged.

The auth server requires a nonce on /authorize when openid is in the
requested scope, so it can echo it back as the nonce claim of the issued
ID token for replay protection. The SDK previously had no way for
developers to supply one.

Add an optional nonce field on AuthContext that AuthProvider forwards to
UniversalSsoLink (via the existing optionalQueryParams map), so it ends
up as the nonce= query param on /authorize. The SDK does not generate,
store, or validate the value — that stays with the caller's backend.

Test Plan: unit tests covering nonce present and absent.
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.

1 participant