Skip to content

[auth] Auto-generate nonce when caller does not provide one#273

Draft
partha-uber wants to merge 3 commits into
sirker-auth-state-csrffrom
sirker-auth-nonce-autogen
Draft

[auth] Auto-generate nonce when caller does not provide one#273
partha-uber wants to merge 3 commits into
sirker-auth-state-csrffrom
sirker-auth-nonce-autogen

Conversation

@partha-uber

@partha-uber partha-uber commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • SDK now auto-generates a cryptographically secure nonce parameter
    (SecureRandom, 32 bytes, base64url) when AuthContext.nonce is null
  • effectiveNonce = authContext.nonce ?: generateSecureToken() ensures
    nonce is always present in SSO query params for replay attack prevention
  • Callers that supply their own nonce (for backend binding) are unaffected
  • @VisibleForTesting effectiveNonce field exposed for assertions

This is step 2/3 of iOS parity (PR #337 in uber-ios-sdk).

Test Plan

Issues

Stack

  1. [auth] Add state (CSRF) parameter to OAuth flow #272
  2. @ [auth] Auto-generate nonce when caller does not provide one #273
  3. [auth] Add id_token field to UberToken and validate nonce claim #274

Summary:
- SDK now auto-generates a cryptographically secure `nonce` parameter
  (SecureRandom, 32 bytes, base64url) when `AuthContext.nonce` is null
- `effectiveNonce = authContext.nonce ?: generateSecureToken()` ensures
  nonce is always present in SSO query params for replay attack prevention
- Callers that supply their own nonce (for backend binding) are unaffected
- `@VisibleForTesting effectiveNonce` field exposed for assertions

This is step 2/3 of iOS parity (PR #337 in uber-ios-sdk).
Summary:
- Verify PKCE flow also forwards the auto-generated nonce
- Verify two different AuthProvider instances produce distinct nonces
  (randomness sanity check)
- Verify effectiveNonce field is stable on repeated reads
@partha-uber partha-uber requested a review from lalwani June 18, 2026 03:07
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