templates icon indicating copy to clipboard operation
templates copied to clipboard

feat(dart): Add Google Sign-In template

Open ahmtydn opened this issue 1 month ago β€’ 2 comments

Description

This PR adds a new Dart template for Google Sign-In authentication with Appwrite Functions. The template verifies Google ID tokens and creates or updates Appwrite users accordingly.

What's Added

  • New Template: dart/sign_in_with_google
    • Token verification using Google's official tokeninfo endpoint
    • Automatic user creation or retrieval
    • Email verification status synchronization
    • Session token generation for Appwrite authentication

Features

βœ… Security Validations:

  • Client ID (audience) verification
  • Token issuer validation (ensures token is from Google)
  • Expiration time checks
  • Official Google tokeninfo endpoint usage

βœ… User Management:

  • Finds existing users by ID or email
  • Creates new users if they don't exist
  • Syncs email verification status from Google to Appwrite
  • Returns session token for client-side authentication

Files Added

  • dart/sign_in_with_google/lib/main.dart - Main function implementation
  • dart/sign_in_with_google/pubspec.yaml - Dart dependencies
  • dart/sign_in_with_google/README.md - Comprehensive documentation with usage examples
  • dart/sign_in_with_google/analysis_options.yaml - Linting configuration
  • dart/sign_in_with_google/.gitignore - Git ignore rules

Documentation

The README includes:

  • Function overview and workflow
  • API usage with request/response examples
  • Configuration requirements
  • Environment variables setup
  • Client-side integration guide using google_sign_in package
  • Security notes and best practices

Testing

The template follows the same pattern as the existing sign_in_with_apple template and uses:

  • dart_appwrite SDK for Appwrite integration
  • http package for Google API communication
  • Official Google tokeninfo endpoint for secure token verification

References

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Google Sign-In authentication with user lookup/creation, email verification handling, and session token issuance.
  • Documentation

    • Added usage and configuration guide with request/response examples, client integration snippet, and security notes.
  • Chores

    • Added package manifest, lint configuration, and ignore patterns for Dart tooling and lockfiles.

✏️ Tip: You can customize this high-level summary in your review settings.

ahmtydn avatar Nov 11 '25 15:11 ahmtydn

Walkthrough

Adds a new Dart package sign_in_with_google with project metadata and tooling files (.gitignore, analysis_options.yaml, pubspec.yaml, README.md) and a runtime at lib/main.dart. The runtime accepts a Google ID token, fetches Google JWKS, verifies JWT signature and claims (kid, audience against GOOGLE_CLIENT_ID, issuer, expiry), extracts user info (sub, email, email_verified, name), and uses Appwrite APIs to find or create a user, update email verification, generate an Appwrite access token, and return userId and token. Error handling covers missing/invalid tokens, key fetch/selection, verification failures, and Appwrite interactions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Files/areas to focus review on:

  • dart/sign_in_with_google/lib/main.dart: JWKS fetch/caching and selection, JWT parsing/signature verification, audience/issuer/expiry checks, handling of email verification, Appwrite user lookup/create/update flows, and error branches.
  • dart/sign_in_with_google/pubspec.yaml: dependency versions and SDK constraint.
  • dart/sign_in_with_google/README.md: request/response schema, runtime/configuration, and security guidance accuracy.
  • dart/sign_in_with_google/.gitignore and dart/sign_in_with_google/analysis_options.yaml: lint and ignore entries.

Pre-merge checks and finishing touches

βœ… Passed checks (3 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title 'feat(dart): Add Google Sign-In template' clearly and directly summarizes the main change: adding a new Google Sign-In authentication template for Dart. It is concise, specific, and accurately reflects the primary purpose of the changeset.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

[!TIP]

πŸ“ Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests β€” including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. πŸ“ Description β€” Summarize the main change in 50–60 words, explaining what was done.
  2. πŸ““ References β€” List relevant issues, discussions, documentation, or related PRs.
  3. πŸ“¦ Dependencies & Requirements β€” Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. πŸ“Š Contributor Summary β€” Include a Markdown table showing contributions: | Contributor | Lines Added | Lines Removed | Files Changed |
  5. βœ”οΈ Additional Notes β€” Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 11 '25 15:11 coderabbitai[bot]

Related:

  • https://github.com/appwrite/appwrite/issues/9015

stnguyen90 avatar Nov 14 '25 22:11 stnguyen90