Skip to content

auth: OAuth2 clients, identity validators, and Phone calling codes - #137

Draft
eldadfux wants to merge 4 commits into
mainfrom
cursor/auth-validators-oauth2-1299
Draft

auth: OAuth2 clients, identity validators, and Phone calling codes#137
eldadfux wants to merge 4 commits into
mainfrom
cursor/auth-validators-oauth2-1299

Conversation

@eldadfux

@eldadfux eldadfux commented Aug 15, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Moves the reusable Appwrite Auth pieces that still lived in appwrite/appwrite into Utopia libraries:

validators

  • New Utopia\Validator\CallingCode (ITU-T E.164 country calling codes, no messaging dependency).
  • Phone gains optional knownCallingCode: true (default false, so existing callers stay valid).

auth

  • Identity validators: Password, PasswordStrength, PasswordDictionary, PasswordHistory, PersonalData, EmailWhitelist, MockNumber.
  • Relying-party OAuth2 clients under Utopia\Auth\OAuth2\Provider / Providers (47 adapters, including the hardcoded Appwrite Cloud provider and VCS helpers on GitHub, GitLab, Gitea, Bitbucket).
  • Injectable HttpClient (curl by default) so tests can point at WireMock without rewriting adapters.
  • PKCE encrypts the verifier with an injected stateEncryptionKey instead of reading Appwrite env vars.
  • Utopia\Auth\OAuth2\Exception is protocol-level (RFC 6749 error / error_description). Product error types stay in Appwrite.

Existing authorization-server helpers (PAR, Prompts, ResourceIndicators, token issuers) are unchanged.

MockNumber constructs new Phone() so it installs against published validators 0.5.0. After a validators release that includes knownCallingCode, pass knownCallingCode: true again.

CI

Follow-up commits green the Tests workflow:

  • Vale: accept allowlists and Etsy.
  • Rector: simplify Phone::isValid() and type CallingCode::CODES.
  • PHPStan: document CODES as array<int, true> (PHP casts numeric string keys to int).
  • Relock packages/dns onto utopia-php/validators 0.5 so linked Docker composer install matches the ^0.5 constraint (left stale by the validators 0.5 dependents bump).

A Split Dev branch cursor/auth-validators-oauth2-1299 is on utopia-php/auth for the Appwrite consume PR (dev-cursor/auth-validators-oauth2-1299 as 0.10.999). The validators mirror is not in this agent's install set, so that package is not split; Appwrite uses published 0.5.0 until a maintainer dispatches Actions → Split Dev for validators on this branch.

Test Plan

  • Phone / CallingCode unit tests (PHPStan clean).
  • Auth unit: GitHub token exchange + errors, PKCE challenge/verifier round-trip across Etsy/X/Kick/Appwrite, login-URL smoke test for every adapter, validator suites.
  • Auth e2e: docker compose up --wait starts WireMock on host port 18080; composer test:e2e exercises GitHub, Google, Appwrite Cloud, and VCS createRepository() against recorded mappings.

Related PRs and Issues

Open in Web Open in Cursor 

Add relying-party OAuth2 adapters (including VCS helpers, PKCE, and the
Appwrite Cloud provider) under Utopia\Auth\OAuth2\Provider, with unit
coverage and WireMock e2e tests.

Password and identity input rules move to Utopia\Auth\Validator. Phone
numbers with a known ITU-T calling code belong on utopia-php/validators
via CallingCode and Phone(knownCallingCode: true).

Co-authored-by: Eldad A. Fux <eldadfux@users.noreply.github.com>
Allow Vale to accept "allowlists" and "Etsy", apply Rector's Phone/CallingCode
simplifications, and relock dns onto validators 0.5 so linked Docker installs
succeed.

Co-authored-by: Eldad A. Fux <eldadfux@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown

Benchmark results

dns — transport throughput (4 cores, 250 repeats x 20 workers x 3 domains per transport)

transport req/s ok p50 ms p95 p99 max
udp 19045.28 15000/15000 1 1 1 3
tcp 17850.59 15000/15000 1 1 1 2
doh 10700.49 15000/15000 1 3 4 11

Shared CI runners — treat absolute numbers as rough, compare modes within a run. Commit 9e6c5e1.

cursoragent and others added 2 commits August 16, 2026 07:58
Numeric string keys in the const become integers in PHP, so the phpdoc
must be array<int, true> rather than array<string, true>.

Co-authored-by: Eldad A. Fux <eldadfux@users.noreply.github.com>
Phone(knownCallingCode: true) is not on Packagist yet. Use the E.164
constructor so Appwrite can require the auth split-dev branch without a
custom validators dist.

Co-authored-by: Eldad A. Fux <eldadfux@users.noreply.github.com>
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