Skip to content

fix(account): apply project email policies to ID-token sign-in on self-hosted - #14633

Merged
abnegate merged 4 commits into
mainfrom
cursor/account-id-token-email-policies-c522
Oct 22, 2026
Merged

abnegate merged 4 commits into
mainfrom
cursor/account-id-token-email-policies-c522

Conversation

@abnegate

Copy link
Copy Markdown
Member

What does this PR do?

ID-token sign-in (POST /v1/account/sessions/id-token) now applies the same project email policies as email/password sign-up, OAuth2 redirect, Users create/update email, and team membership creation.

Those other paths treat an empty injected plan (self-hosted) as allowing the project's configured policies. The ID-token path only checked console or a populated plan feature flag, so self-hosted skipped the checks. Cloud behaviour is unchanged: a populated plan still gates each policy on the matching supports* flag.

The gate in parseEmail() (canonicalize) and assertEmailPolicy() now matches the existing expression used elsewhere:

console || empty($plan) || $plan['supports…']

This covers both new-user creation and the email backfill path. A shared helper was considered; the existing inline expression was kept so this file stays consistent with the other call sites.

Test Plan

  • Pint and PHPStan on the changed files.
  • New Account e2e coverage in AccountCustomClientTest for deny-free-email and deny-disposable-email on the ID-token path:
    • email/password sign-up is rejected (policy is active)
    • new-user ID-token sign-in is rejected
    • email backfill on an existing ID-token user is rejected
    • a non-matching address still signs in while the policy is on
    • policies are disabled in finally so later tests are unaffected
docker compose exec appwrite test tests/e2e/Services/Account --filter=testCreateIdTokenSessionDenyFreeEmail
docker compose exec appwrite test tests/e2e/Services/Account --filter=testCreateIdTokenSessionDenyDisposableEmail

Related PRs and Issues

  • Aligns ID-token sign-in with the email-policy gate introduced alongside that feature

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web Open in Cursor 

…f-hosted

ID-token sign-in now uses the same plan gate as email sign-up, OAuth2,
and user/membership email updates so project email policies apply when
the injected plan is empty.

Co-authored-by: Jake Barnby <[email protected]>
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → cursor/account-id-token-email-policies-c522 (after).

Metric Before After Change
🚀 Requests/sec 204.44 209.47 ⚪ +2.5%
⏱️ Latency P50 85.51 ms 80.82 ms 🟢 -5.5%
⏱️ Latency P95 200.4 ms 196.67 ms ⚪ -1.9%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 80.82 196.67 13,224 209.47 -3.72
Account 160.15 281.18 696 11.54 -7.21
TablesDB 75.76 143.45 7,192 116.68 -22.2
Storage 80.14 191.86 3,480 57.82 +10.19
Functions 118.38 228.58 1,856 31.6 +4.31

Top API waits (after)

API request Max wait (ms)
functions.create 473.45
functions.variables.create 432.93
functions.variables.update 427.64
storage.buckets.create 407.8
account.name.update 376.92

@abnegate
abnegate marked this pull request as ready for review October 22, 2026 00:48
@luxor-code-review

luxor-code-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR introduces a new POST /v1/account/sessions/idtoken action that authenticates users via a provider ID token (Apple/Google), creating a new user or backfilling an existing one from verified token claims, with email canonicalization and email-policy checks aligned with the existing OAuth2 flow. An e2e test suite covers the new route success and failure paths.

Files Change
src/Appwrite/Platform/Modules/Account/Http/Account/Sessions/IdToken/Create.php New HTTP action exchanging a provider ID token for a session, with canonical email handling and email-policy enforcement mirroring the existing OAuth2 sign-in flow.
tests/e2e/Services/Account/AccountCustomClientTest.php E2E tests covering session creation via ID token, including new-user and error cases.

Reviewed commit: 5c88aaf

@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The changed gates match the established self-hosted behavior, and the added E2E cases cover the affected paths.

The ID-token sign-in flow now treats an empty plan as allowing configured email policies, matching other self-hosted account paths while retaining Cloud plan-feature gating. E2E coverage exercises free, disposable, aliased, and corporate email policies for sign-up, new-user sign-in, backfill, and allowed addresses.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Platform/Modules/Account/Http/Account/Sessions/IdToken/Create.php Apply project email policy gates when the injected plan is empty, including canonicalization.
tests/e2e/Services/Account/AccountCustomClientTest.php Add policy regression coverage for ID-token sign-in, backfill, and canonicalization.

Reviewed 6de02cb · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost 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.

🟢 Tier S · Looks good to merge. Summary

Co-authored-by: Jake Barnby <[email protected]>
@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@hansi-codes review

@ghost ghost 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.

🔵 Tier A · Looks good to merge. Summary

@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@hansi-codes review

@ghost ghost 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.

🔵 Tier A · Looks good to merge. Summary

@ghost ghost 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.

🟢 Tier S · Looks good to merge. Summary

@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@hansi-codes review

@ghost ghost 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.

🟢 Tier S · Looks good to merge. Summary

@abnegate
abnegate merged commit 04d8428 into main Oct 22, 2026
38 checks passed
@abnegate
abnegate deleted the cursor/account-id-token-email-policies-c522 branch October 22, 2026 05:38
imtia33 pushed a commit to imtia33/appwrite that referenced this pull request Oct 22, 2026
… them

The ID-token email policy tests from appwrite#14633 enable deny-free-email,
deny-disposable-email, deny-aliased-email and deny-corporate-email
through the project policies API, which refuses each with
general_access_forbidden on a Cloud plan that lacks the feature. Cloud
runs this suite on such a plan, so all four tests failed in setup.
Skip them there, the way MigrationsBase already tolerates the same
refusal; self-hosted has an empty plan and still runs them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…en-email-policies-c522

fix(account): apply project email policies to ID-token sign-in on self-hosted

(cherry picked from commit 04d8428)
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