-
Notifications
You must be signed in to change notification settings - Fork 243
Third party auth not working with Storage #3362
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
Comments
I am having a similar issue, which I had posted (along with another issue today) the following: I'm setting up local development using Setup:
Problem:
Key Observation:
Has anyone seen this behavior where the Thanks! |
Also adding that I am seeing this issue on local development. I only see it when trying to do anything with storage, normal tables within the public schema seem to work correctly. When tested with a live cloud version of supabase, it works correctly. |
Okay @AidanFogarty looks like I figured out a solution - if you go and install their latest pre-release it works again. I dont know if you need to install v2.20.12 but something somewhere between that and v2.20.5 solved this for me! For Apple Silicon, here are the steps
|
I am not sure this actually does fix it. The error popped back up. |
We have started seeing this today as well, when uploading an image. The code has been in production unchanged for a few months, not sure why the issue just started. Switching to using await supabaseAdmin.storage instead of await supabase.storage DOES fix the issue, but that should not be necessary |
Looking at the code I don't think it ever worked. Are you using the cli setup in prod? |
Yes but we have not pushed a schema change between when this was working and now |
I'm having the same issue. I use supabase with clerk. It was working a couple of days ago then today I started getting 403 - invalid algorithm. Inserting into the database works, but as soon as I want to upload a file to storage, I run into this issue. I have RLS policies set up for all the tables and storage. |
I am also having the same issue with my Supabase-Clerk integration. I resorted to fetching a templated token conditionally (only for requests to the storage endpoint). I'll leave this here in case it helps anyone else: function createSupabaseClient() {
return createClient<Database>(SUPABASE_URL, SUPABASE_ANON_KEY, {
global: {
fetch: async (url, options) => {
let token: string | null | undefined = null;
if (isStorageRequest(url)) {
token = await window.Clerk.session?.getToken({ template: "supabase" });
} else {
token = await window.Clerk.session?.getToken();
}
const headers = new Headers(options?.headers);
if (token) {
headers.set("Authorization", `Bearer ${token}`);
}
return fetch(url, {
...options,
headers,
});
},
},
});
} |
It'd be great to get a Supabase person here, but I get the impression that the Clerk issue is different and should have a different thread. Just guessing based on the context. |
Opened a separate issue for the error with Clerk: supabase/supabase#34948 |
Hi guys, I tried to debug the I tried to paste my user session token on jwt.io and got "signature verified", All public JWK matches with the ones exported here |
On Clerk stuff: |
The incident impacting Clerk integration (and most 3rd party auth using storage) has been resolved. It was caused by a change that went in to production yesterday. The fix for it has now been deployed in all regions and this problem should be resolved. However, the issue @martinbaste is facing is separate as it predates this change by a couple weeks. I've passed this issue along to the Auth team to investigate further. |
@martinbaste Is the issue still relevant? |
Yes, AFAIK no code has been deployed to fix it. So it's still failing to properly authenticate users on Supabase CLI (Storage) when Cognito (and probably other third party auth) is used. So yes, would be great if the Auth team can take a look. My initial post highlights where I think the issue is, but I'm no expert in the Supabase CLI codebase. I think we're just not passing the right env variables to the Storage docker container. |
Describe the bug
I've searched issues, discussions and discord.
I'm trying to use a Cognito JWT with Supabase. I've followed the documentation to integrate with Cognito.
Fetching from Supabase database works fine using the JWT. But trying to get private files from Storage fails with the error 'invalid algorithm'.
I'm running it locally.
I've checked the source code and I wonder if there is a bug with the environment variables, I wanted to double check here if someone has successfully gotten it to work.
I suspect there is a mismatch between the environment variables that the supabase cli creates (see here, notice AUTH_JWT_ALGORITHM is also not set) and what Storage expects (see here)
I tested the JWT against the cloud Supabase Storage and it seems to work, so it looks like a bug in Supabase CLI.
To Reproduce
Configure Supabase to use Cognito for auth
config.toml
Send a POST request to sign an image with the JWT token in the Auth Bearer header:
http://127.0.0.1:54321/storage/v1/object/sign/bucket/image.jpeg
I get an invalid algorithm error
From looking at the code (see links above), I think that the issue is caused by the Storage docker container not getting the right environment variables. I've tested this in the cloud version of Supabase and I suspect it works (I get a 404 because I haven't fixed the policies, but it goes past the JWT check).
Again, fetching data from the Supabase Database works with my JWT, so I know its valid.
Expected behavior
Once configuring Cognito as third party auth, I'd expect Storage to accept its JWT.
Screenshots
N/A
System information
No specific command fails but this is my system info
Additional context
The text was updated successfully, but these errors were encountered: