8000 feat: add figma oauth provider by ChiragAgg5k · Pull Request #9623 · appwrite/appwrite · GitHub
[go: up one dir, main page]

Skip to content

feat: add figma oauth provider#9623

Merged
christyjacob4 merged 2 commits into1.6.xfrom
feat-figma-oauth
Apr 8, 2025
Merged

feat: add figma oauth provider#9623
christyjacob4 merged 2 commits into1.6.xfrom
feat-figma-oauth

Conversation

@ChiragAgg5k
Copy link
Member
@ChiragAgg5k ChiragAgg5k commented Apr 8, 2025

What does this PR do?

Adds figma oauth provider - https://www.figma.com/developers/api#oauth2

Test Plan

Screenshot 2025-04-08 at 2 12 19 PM

Related PRs and Issues

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?

Summary by CodeRabbit

  • New Features

    • Added Figma OAuth support, allowing users to sign in using their Figma accounts.
  • Documentation

    • Updated API specifications and OAuth provider details to include Figma support and reflect the latest provider options with enhanced versioning.

@coderabbitai
Copy link
Contributor
coderabbitai bot commented Apr 8, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces a new OAuth provider, Figma, by adding its configuration details, updating API specifications, and implementing a dedicated OAuth2 class for Figma. The changes include modifications to both OpenAPI and Swagger specification files with version updates from 1.6.1 to 1.6.2, adjustments to provider parameter descriptions and enumerations, and the removal of an outdated enum value. Additionally, a new class in the OAuth2 namespace encapsulates Figma’s OAuth2 authentication flow including login redirection, token exchange, token refresh, and user data retrieval.

Changes

File(s) Change Summary
app/config/oAuthProviders.php Added a new entry for the 'figma' provider with attributes (name, developers URL, icon, enabled, sandbox, form, beta, mock).
app/config/specs/open-api3-latest-*.json Incremented version from 1.6.1 to 1.6.2; updated OAuth2 provider descriptions/enums to include 'figma'; removed "fra" from enum in console spec.
app/config/specs/swagger2-latest-*.json Incremented version from 1.6.1 to 1.6.2; updated OAuth2 provider descriptions/enums to include 'figma'; removed "fra" from enum in console spec.
src/Appwrite/Auth/OAuth2/Figma.php Introduced a new Figma class for OAuth2 handling with methods to generate login URLs, exchange authorization codes for tokens, refresh tokens, and retrieve user data such as ID, email, and username.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant FigmaAPI

    User->>App: Click on "Login with Figma"
    App->>User: Redirect to Figma OAuth login (getLoginURL)
    User->>FigmaAPI: Login & authorize application
    FigmaAPI-->>User: Redirect back with authorization code
    User->>App: Provide authorization code to callback endpoint
    App->>FigmaAPI: POST authorization code to token endpoint (getTokens)
    FigmaAPI-->>App: Return access/refresh tokens
    App->>FigmaAPI: Request user data using access token (getUser)
    FigmaAPI-->>App: Return user information
    App->>User: Complete login process with retrieved user data
Loading

Poem

In a world of code so bright,
I hopped along to add some light.
Figma’s now in our OAuth crew, 🐇
Tokens dance, and flows renew.
A rabbit’s cheer for changes new,
Leaping high with every breakthrough!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ChiragAgg5k
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor
coderabbitai bot commented Apr 8, 2025
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
github-actions bot commented Apr 8, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH
xz 5.6.2-r0 CVE-2025-31115 HIGH
xz-libs 5.6.2-r0 CVE-2025-31115 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

@pkg-pr-new
Copy link
pkg-pr-new bot commented Apr 8, 2025

Open in StackBlitz

npm i https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@9623

commit: 2c453d5

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
app/config/specs/open-api3-latest-console.json (1)

1937-1943: Provider Enumeration List Update

The enumeration list for OAuth2 providers now includes "figma" (placed after "facebook" and before "github"). If the order is significant (e.g., alphabetical sorting or logical grouping), please confirm that the position of "figma" is intentional.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a20ff31 and 3bd8405.

📒 Files selected for processing (8)
  • app/config/oAuthProviders.php (1 hunks)
  • app/config/specs/open-api3-latest-client.json (5 hunks)
  • app/config/specs/open-api3-latest-console.json (7 hunks)
  • app/config/specs/open-api3-latest-server.json (3 hunks)
  • app/config/specs/swagger2-latest-client.json (5 hunks)
  • app/config/specs/swagger2-latest-console.json (7 hunks)
  • app/config/specs/swagger2-latest-server.json (3 hunks)
  • src/Appwrite/Auth/OAuth2/Figma.php (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/Appwrite/Auth/OAuth2/Figma.php (2)
src/Appwrite/Auth/Auth.php (1)
  • Auth (18-510)
src/Appwrite/Auth/Key.php (1)
  • getScopes (41-44)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup & Build Appwrite Image
🔇 Additional comments (35)
app/config/specs/open-api3-latest-client.json (4)

4-4: Version increment looks correct.

The version number has been properly incremented from 1.6.1 to 1.6.2 which is appropriate for adding a new OAuth provider functionality.


1905-1905: Figma OAuth provider correctly added to documentation and enumeration.

The Figma OAuth provider has been properly added to the provider description text and to the enum list in alphabetical order, which maintains consistency with the other providers.

Also applies to: 1925-1925


2782-2782: Consistent addition of Figma provider across all relevant sections.

The Figma OAuth provider has been properly added to the second occurrence of provider descriptions and enumerations, ensuring consistency throughout the specification.

Also applies to: 2802-2802


1905-1905:

Details

✅ Verification successful

Verify that implementation matches documentation.

While the specification has been updated correctly, it's important to ensure that the actual implementation of the Figma OAuth provider exists and matches what's described in the specification.

Also applies to: 2782-2782


🏁 Script executed:

#!/bin/bash
# Check if there's a corresponding implementation file for the Figma OAuth provider

# Check for OAuth provider class implementation
echo "Checking for Figma OAuth provider implementation:"
fd --type f "Figma.php" src/Appwrite/Auth/OAuth2/

# Check for the provider configuration in the OAuth providers file
echo -e "\nChecking for Figma in OAuth providers configuration:"
fd oAuthProviders.php app/config/ --exec grep -n "figma" {}

Length of output: 508


Figma OAuth Provider Implementation Verified

The Figma OAuth provider implementation has been confirmed. Specifically:

  • Implementation File: src/Appwrite/Auth/OAuth2/Figma.php exists.
  • Provider Configuration: The Figma provider is correctly configured in app/config/oAuthProviders.php (lines 145-148) with the expected details.

These findings confirm that the implementation matches the updated documentation. No further changes are needed.

app/config/specs/swagger2-latest-client.json (6)

4-4: Version updated appropriately.

The version has been bumped from 1.6.1 to 1.6.2, which is appropriate for adding a new OAuth provider as this represents a minor feature addition without breaking changes.


2031-2032: Documentation updated to include Figma provider.

The provider description has been updated to include "figma" in the list of supported OAuth2 providers, correctly documenting the new capability.


2050-2050: Figma added to OAuth provider enum.

The "figma" provider has been correctly added to the enum list of supported OAuth providers for the create OAuth2 session endpoint.


2936-2937: Documentation updated consistently across endpoints.

The description for the OAuth2 token endpoint has been similarly updated to include "figma" provider, maintaining consistency with the session creation endpoint.


2955-2955: Figma added to token endpoint's provider enum.

The "figma" provider has been correctly added to the enum list for the OAuth2 token endpoint, ensuring consistency across related API operations.


4-4:

Details

✅ Verification successful

Verify the implementation consistency across the entire application.

The spec file changes look good, but to ensure full implementation consistency, make sure that the Figma OAuth provider is properly implemented and registered in the following components:

  1. OAuth providers configuration
  2. Figma OAuth2 implementation class
  3. Any related validation logic
  4. Documentation updates for users

Also applies to: 2031-2032, 2050-2050, 2936-2937, 2955-2955


🏁 Script executed:

#!/bin/bash

# Check if Figma is added to OAuth providers configuration
echo "Checking OAuth providers configuration..."
grep -r "figma" app/config/oAuthProviders.php

# Check if Figma OAuth2 implementation class exists
echo "Checking Figma OAuth2 implementation class..."
find src -name "Figma.php" | grep -i "Auth/OAuth2"

# Check if class follows the same pattern as other OAuth2 providers
echo "Checking implementation pattern..."
if [ -f "$(find src -name "Figma.php" | grep -i "Auth/OAuth2")" ]; then
  head -n 20 "$(find src -name "Figma.php" | grep -i "Auth/OAuth2")"
fi

Length of output: 1042


Figma OAuth Provider Implementation Verified

The spec file changes look good. Based on the verification:

  • The OAuth providers configuration in app/config/oAuthProviders.php correctly registers Figma.
  • The Figma OAuth2 implementation class exists at src/Appwrite/Auth/OAuth2/Figma.php and follows the expected implementation pattern.
  • Please ensure that any related validation logic and documentation updates for Figma are in sync with these changes.
app/config/oAuthProviders.php (1)

145-154: Well-structured Figma OAuth provider implementation.

The new Figma OAuth provider is correctly implemented following the same structure as other providers. It's also properly positioned alphabetically between Facebook and GitHub, maintaining the order as noted in the comment on line 3.

app/config/specs/swagger2-latest-server.json (3)

1-7: Version Update Consistency

The API version has been updated from "1.6.1" to "1.6.2", which accurately reflects the introduction of new functionality (i.e., the Figma OAuth provider). This version bump aligns with our versioning strategy when adding support for additional providers.

🧰 Tools
🪛 Checkov (3.2.334)

[HIGH] 1-26880: Ensure that the global security field has rules defined

(CKV_OPENAPI_4)


2628-2634: Enhanced Provider Parameter Description

The "description" field for the "provider" parameter has been extended to explicitly include "figma" alongside the other supported providers. This change improves clarity for clients integrating with the API.


2647-2653: Addition of Figma in Supported Providers List

By inserting "figma" into the array of supported providers, this update completes the integration of the new OAuth provider. The change is well aligned with the overall objective of expanding OAuth2 support.

app/config/specs/open-api3-latest-server.json (3)

3-7: Version Update:
The OpenAPI specification version has been updated from "1.6.1" to "1.6.2", which is consistent with the PR objectives. Please ensure that this version update is synchronized with corresponding specification files elsewhere in the codebase.


2464-2470: Provider Description Enhancement:
The "provider" parameter description now includes "figma" as one of the supported OAuth2 providers. This clear listing enhances documentation accuracy. Verify that the list order and content match the expected provider configurations across other specification files.


2484-2490: Enumeration Update:
"figma" has been added to the enumerated list of valid OAuth2 providers. The update appears correct; ensure consistency with any related enum definitions or usage within the OAuth provider implementations.

app/config/specs/open-api3-latest-console.json (6)

1-7: API Version Update

The version has been updated from "1.6.1" to "1.6.2", which aligns with the overall release update. Please verify that all other specification files are in sync with this new version.


1917-1923: Provider Description Enhancement

The description for the "provider" parameter now includes "figma" among the supported OAuth2 providers. This update meets the PR objective of adding the Figma OAuth provider. Ensure that similar changes in other spec files (client, server, etc.) remain consistent.


2787-2793: Consistent Update in Provider Description

This hunk similarly updates the "provider" parameter description to include "figma". The change is consistent with the earlier update and supports a uniform specification across endpoints.


2807-2813: Consistent Provider Enum Update

The provider enumeration in this section has been updated to include "figma" as well. This consistent update across the spec helps ensure that all endpoints recognize the new provider.


19058-19064: Removed Obsolete Enum Value for Project Region

The enum now lists only ["default"], with the removal of "fra". This update appears to align with current project region support. However, please verify that there are no legacy clients or dependencies expecting the "fra" value.


20881-20887: Final Provider Enum Confirmation

The enumeration for providers here also reflects the inclusion of "figma", ensuring consistency. Double-check that all relevant endpoints and documentation have been updated to match these changes.

app/config/specs/swagger2-latest-console.json (7)

4-4: Version Update: "1.6.2"
The version field in the info section has been updated to "1.6.2" as expected. Please ensure that any downstream services or documentation referencing the version are also updated accordingly.


2061-2062: Provider Description Enhancement
The description for the "provider" parameter now explicitly includes "figma" alongside other supported providers. This improves clarity in the API specification. Verify that the authentication flow for Figma is implemented consistently elsewhere.


2078-2084: Enumeration Update: "figma" Inclusion
The enumeration for supported providers now contains "figma". Confirm that the ordering is intentional and that the actual OAuth implementation supports "figma" as described in the API documentation.


2959-2960: Consistent Provider Parameter Description
In this section, the "provider" parameter’s description has been updated to include "figma", matching the changes in other parts of the documentation. Ensure consistency across all config files.


2979-2980: Enumeration Inclusion: "figma" Added
The "figma" provider has been inserted into the enumeration list within this parameters block. This aligns with the overall updates to support Figma. Please verify that this new entry reflects the intended order and functionality.


19527-19528: Enum Cleanup: Removed "fra"
The enum value "fra" has been removed, leaving only "default". This cleanup ensures that only valid and supported values remain. Confirm that this change does not affect any dependent configurations.


21355-21356: Provider Enum Update: "figma" Included
Here, "figma" is added into the provider enum list. Ensure that this addition is consistent with both the UI and backend expectations for OAuth2 providers.

src/Appwrite/Auth/OAuth2/Figma.php (5)

1-10: Code follows proper structure and includes relevant documentation references.

The class properly includes references to Figma's API documentation, which is excellent for future maintainers. The namespace and imports follow the project's structure.


104-114: Method correctly handles user ID extraction.

The implementation properly handles the case where user ID might not be available.


116-126: Method correctly handles email extraction.

The implementation properly handles the case where email might not be available.


145-155: Method correctly handles username extraction.

The implementation properly extracts the 'handle' field as the username and handles cases where it might not be available.


128-143:

Details

✅ Verification successful

Verify the email verification assumption.

The comment explains that Figma requires email verification during signup, which justifies the implementation. However, it would be good to confirm this with Figma's documentation to ensure it remains true.


🌐 Web query:

Does Figma require email verification during signup?

💡 Result:

Figma requires email verification during the signup process. After creating an account with an email address and password, users receive a verification email to confirm their email address[6]. This step is mandatory to complete the registration.

Common scenarios where verification is required:

  • New accounts: Users must click the "verify email" button in the email sent by Figma to activate their account[6].
  • Education plans: Users signing up for educational status have seven days to verify their email and education details. Failure to do so restricts access to team files and projects[4].
  • Team invitations: Members joining a team via email invitation must verify their email address to gain access[4].

Troubleshooting verification issues:

  • If the verification email isn’t received, check spam/junk folders[2].
  • Some users reported issues with business or Outlook emails not receiving verification emails, while personal addresses (e.g., Hotmail) worked immediately[2].
  • If emails are consistently blocked, Figma Support may need to resolve holds caused by past rejected messages[2]. Contacting support@figma.com is recommended in such cases[2].

Verification ensures account security and compliance with Figma's authentication policies[1][4][6].

Citations:


Figma Email Verification Assumption Confirmed

After reviewing Figma's documentation, it has been confirmed that Figma indeed requires email verification during signup. The logic in the isEmailVerified method (i.e., returning true when a non-empty email is present) aligns with this requirement. No further changes are needed.

@github-actions
Copy link
github-actions bot commented Apr 8, 2025

✨ Benchmark results

  • Requests per second: 1,042
  • Requests with 200 status code: 187,671
  • P99 latency: 0.174740026

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,042 1,270
200 187,671 228,604
P99 0.174740026 0.146635166

@christyjacob4 christyjacob4 merged commit 881525f into 1.6.x Apr 8, 2025
33 checks passed
@christyjacob4 christyjacob4 deleted the feat-figma-oauth branch April 8, 2025 12:57
@stnguyen90 stnguyen90 moved this to Done in 1.6 Release May 1, 2025
@coderabbitai coderabbitai bot mentioned this pull request May 14, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

0