Skip to content
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

Accept Supabase OAuth token #292

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dobrac
Copy link
Contributor

@dobrac dobrac commented Feb 11, 2025

Allow using Supabase OAuth token instead of Team API Keys or user Access Tokens as authentication method.

Usage requires following headers for Team API endpoints:

X-Supabase-Token: ${Supabase JWT}
X-Supabase-Team: ${Team ID}

And following for Access Token endpoints:

X-Supabase-Token: ${Supabase JWT}

This change requires also infrastructure update and setting up supabase_jwt_secret in Google Secret Manager.

Note: The naming securitySchemes with 1 and 2 is there for having the verification in correct order.

Copy link

linear bot commented Feb 11, 2025

@dobrac dobrac force-pushed the accept-supabase-oauth-token-e2b-1563 branch from ef997e4 to 7ef079f Compare February 11, 2025 18:32
@dobrac dobrac self-assigned this Feb 11, 2025
@dobrac dobrac added the feature New feature label Feb 11, 2025
@dobrac dobrac marked this pull request as draft February 11, 2025 18:52
@dobrac dobrac marked this pull request as ready for review February 11, 2025 20:09
@dobrac dobrac force-pushed the accept-supabase-oauth-token-e2b-1563 branch from 4dbb9b0 to 3c863b5 Compare February 14, 2025 00:31
@ValentaTomas ValentaTomas requested a review from 0div February 24, 2025 03:27
Copy link
Contributor

@0div 0div left a comment

Choose a reason for hiding this comment

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

LGTM, mostly nits, some questions tho:

  • possible to write a test since this is now abstracted as an interface?
  • if not, how to test this manually?
  • what is the mitigation plan if secret key leaks? (and how to better store it?)
  • how will we handle secret key rotation?

@dobrac
Copy link
Contributor Author

dobrac commented Feb 24, 2025

  • possible to write a test since this is now abstracted as an interface?

There could be some tests for sure now, especially if we merge the integration ones.

  • if not, how to test this manually?

You can get the JWT secret from Supabase prod & get the Supabase token from the dashboard (or you can get the JWT secret from your Supabase instance and generate your own token, you just need to set "subject" to your user uuid).

Then just start the API locally and try to call http endpoints with the headers.

  • what is the mitigation plan if secret key leaks? (and how to better store it?)
  • how will we handle secret key rotation?

If you mean the tokens themselves, that would follow the same as if user token leaks (those supabase tokens are directly generated for the user). If the JWT secret leaks, we would have to manually rotate it. For secret saving, I agree that using Hashicorp Vault might be better, but we don't have it set up rn afaik.
To rotate JWT token, this is a good point, when we need to do it, we might need to temporarily accept more than one version of it. Do you have any better idea how to handle it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants