Skip to content

Added supabase auth page and updated examples #1838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 28, 2025
Merged

Conversation

D-K-P
Copy link
Member

@D-K-P D-K-P commented Mar 28, 2025

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive Supabase authentication guide covering JWT and service role methods.
    • Expanded and updated multiple guides and examples to improve authentication instructions and warnings.
    • Introduced an enhanced documentation card layout with easy access to the new Supabase authentication guide.
    • Provided clearer examples and notes to assist users in securely setting up and using Supabase features.

Copy link

changeset-bot bot commented Mar 28, 2025

⚠️ No Changeset found

Latest commit: 0058c5f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

Walkthrough

The pull request updates several Supabase-related documentation files and examples. It adds a new documentation page for Supabase authentication and modifies examples to use JWT-based authentication instead of a service role key. Several MDX files now import and display the SupabaseAuthInfo component, and minor adjustments have been made in UI elements (like warning tags and card layouts) to enhance clarity.

Changes

File(s) Change Summary
docs/docs.json Added a new page entry "guides/frameworks/supabase-authentication" under the Supabase group in the Guides section.
docs/guides/examples/supabase-database-operations.mdx, trigger/supabase-database-insert.ts Modified Supabase client initialization: replaced service role key usage with JWT-based authentication by reading environment variables, generating a JWT token, and importing SupabaseAuthInfo.
docs/guides/examples/supabase-storage-upload.mdx, docs/guides/frameworks/supabase-edge-functions-basic.mdx, docs/guides/frameworks/supabase-edge-functions-database-webhooks.mdx Added import of SupabaseAuthInfo and inserted the component; updated warning/note tags and messaging for authentication guidance.
docs/guides/frameworks/supabase-authentication.mdx Created a new documentation file outlining authentication methods for Supabase tasks, detailing JWT and service role key usage.
docs/snippets/supabase-auth-info.mdx, docs/snippets/supabase-docs-cards.mdx Added a note for configuring Supabase authentication and updated the card layout to include a new "Supabase authentication guide" card with modified column settings.

Sequence Diagram(s)

sequenceDiagram
    participant Task
    participant Env as Environment Variables
    participant JWT as JWT Generator
    participant Client as SupabaseClient
    Task->>Env: Fetch SUPABASE_JWT_SECRET
    Env-->>Task: Return JWT secret
    alt Secret Missing
       Task->>Task: Throw error for missing secret
    else Secret Present
       Task->>JWT: Generate JWT token using secret
       JWT-->>Task: Return JWT token
       Task->>Client: Initialize client with SUPABASE_URL, SUPABASE_ANON_KEY, and JWT token in headers
       Client-->>Task: Acknowledge client initialization
       Task->>Client: Execute database insert
       Client-->>Task: Return operation result
    end
Loading

Possibly related PRs

Suggested reviewers

  • samejr
  • matt-aitken

Poem

I'm a rabbit in a code-filled glen,
Hopping through docs again and again.
With JWTs and tips so bright,
Supabase guides now shine in light.
My ears twitch with each update sound—
In this digital burrow, joy is found!
🐇✨


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
🪧 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.

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: 0

🧹 Nitpick comments (1)
docs/guides/frameworks/supabase-authentication.mdx (1)

13-16: Consider Rewording Repetitive Sentence Beginnings

In the introductory section for JWT Authentication, multiple sentences start with similar words (e.g., "This"). Consider varying the sentence openings for improved readability. For example, you might rephrase one of the sentences to avoid redundancy.

🧰 Tools
🪛 LanguageTool

[style] ~16-~16: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ase project settings under Data API. This example code shows how to create a JWT ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 49c43a1 and 0058c5f.

📒 Files selected for processing (8)
  • docs/docs.json (1 hunks)
  • docs/guides/examples/supabase-database-operations.mdx (3 hunks)
  • docs/guides/examples/supabase-storage-upload.mdx (2 hunks)
  • docs/guides/frameworks/supabase-authentication.mdx (1 hunks)
  • docs/guides/frameworks/supabase-edge-functions-basic.mdx (2 hunks)
  • docs/guides/frameworks/supabase-edge-functions-database-webhooks.mdx (3 hunks)
  • docs/snippets/supabase-auth-info.mdx (1 hunks)
  • docs/snippets/supabase-docs-cards.mdx (2 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/guides/frameworks/supabase-authentication.mdx

[style] ~16-~16: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ase project settings under Data API. This example code shows how to create a JWT ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (23)
docs/snippets/supabase-auth-info.mdx (1)

1-6: New Supabase Auth Info Documentation Note Added
The note clearly explains how to configure Supabase authentication for Trigger.dev tasks and provides a direct link to the Supabase Authentication guide. The formatting and wording are clear and informative.

docs/docs.json (1)

284-285: New Supabase Authentication Page Entry Added
The new page entry "guides/frameworks/supabase-authentication" has been added correctly under the Supabase guides section. Please verify that its placement and ordering align with the overall navigation structure.

docs/snippets/supabase-docs-cards.mdx (1)

5-27: Updated Card Layout with Supabase Authentication Guide Card
Changing the <CardGroup> to use a single column (cols={1}) and adding the new card for the "Supabase authentication guide" (with the appropriate title, icon, and href) enhances the user experience. This update ties in well with the new authentication documentation.

docs/guides/examples/supabase-storage-upload.mdx (2)

7-8: Importing SupabaseAuthInfo Component
A new import statement for SupabaseAuthInfo has been added. The absolute import path (/snippets/supabase-auth-info.mdx) appears correct if that’s the project’s convention. Confirm that this works as expected in your MDX setup.


141-142: Embedding SupabaseAuthInfo for Enhanced Guidance
The addition of <SupabaseAuthInfo /> provides valuable authentication information for users within this guide. Its placement looks appropriate, but please verify that it integrates well with the surrounding content.

docs/guides/frameworks/supabase-edge-functions-database-webhooks.mdx (4)

15-15: New Import of SupabaseAuthInfo
The file now imports SupabaseAuthInfo from /snippets/supabase-auth-info.mdx, which promotes consistent authentication guidance across the documentation.


140-144: Infinite Loop Warning Added
A new <Warning> block has been introduced to caution users against causing infinite loops when updating tables triggered by a database change. This is a helpful precaution that can prevent serious runtime issues.


244-247: Service Role Secret Key Warning Clarified
The updated warning regarding the service role secret key highlights its potential security risks by noting that it bypasses Row Level Security. This clear indication is vital for users, especially in production environments.


249-250: Authentication Information Component Integrated
The inclusion of <SupabaseAuthInfo /> immediately after the service role secret key warning effectively directs users to further authentication guidance. This helps ensure that users understand the best practices for securing their tasks.

docs/guides/frameworks/supabase-edge-functions-basic.mdx (3)

20-20: Added SupabaseAuthInfo Import

The new import for SupabaseAuthInfo is correctly added. This ensures that authentication-related information will be centrally available in the guide.


114-117: Changed to <Warning> Tag for JWT Option Clarification

Switching from a <Note> to a <Warning> tag helps emphasize the caution around using the --no-verify-jwt flag. The explanation is clear and sets the right context for users.


119-119: Inserted SupabaseAuthInfo Component

The addition of the <SupabaseAuthInfo /> component at the appropriate position enhances the documentation by providing centralized authentication details.

docs/guides/examples/supabase-database-operations.mdx (6)

8-8: Added SupabaseAuthInfo Import

The new import of SupabaseAuthInfo is consistent with related examples and documentation files. It will help provide users with centralized authentication guidance.


31-31: JWT Library Import Added

Importing jwt from "jsonwebtoken" is necessary for creating the JWT token later in the task. This addition correctly supports the JWT-based authentication flow.


40-44: JWT Secret Environment Variable Check

The newly added code block retrieves the SUPABASE_JWT_SECRET environment variable and properly checks for its existence. This validation is essential for security.


46-48: JWT Token Creation

Creating a JWT token with an expiration of 1 hour is implemented clearly using jwt.sign. This block correctly reflects the intended authentication mechanism.


50-60: Supabase Client Initialization with JWT

The initialization of the Supabase client using the JWT via the Authorization header is well implemented. This ensures the client respects Row Level Security (RLS) via the signed token.


79-79: Inserted SupabaseAuthInfo Component

Adding <SupabaseAuthInfo /> at the end of the document reinforces the availability of centralized authentication information.

docs/guides/frameworks/supabase-authentication.mdx (5)

1-6: Front Matter Configuration

The front matter is correctly set up with an appropriate title, sidebar title, and description. This metadata properly introduces the new authentication guide.


7-7: Importing SupabaseDocsCards Component

The import of SupabaseDocsCards is appropriate for displaying related documentation cards later in the file.


19-50: JWT Authentication Code Example Review

The code snippet clearly demonstrates how to:

  • Retrieve the JWT secret from environment variables with error handling.
  • Create a JWT token for a given user with a one-hour expiry.
  • Initialize the Supabase client using the JWT in the Authorization header.

One suggestion is to ensure that the snippet context mentions any required imports (such as for jwt and createClient), if not shown elsewhere in the documentation. Overall, the snippet is comprehensive and informative.


63-73: Service Role Key Authentication Example Review

The code example for using the Service Role Key is concise and clearly demonstrates how to initialize the Supabase client with admin privileges. The accompanying <Warning> tag correctly highlights the security implications of using this key.


75-75: Inserted SupabaseDocsCards Component

The inclusion of <SupabaseDocsCards /> at the end of the document helps users navigate to related documentation. It is a useful addition that enhances the overall flow of information.

@D-K-P D-K-P merged commit fc7e196 into main Mar 28, 2025
7 checks passed
@D-K-P D-K-P deleted the docs/supabase-auth branch March 28, 2025 11:55
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