Upcoming changes to Supabase API Keys #29260
Replies: 44 comments 76 replies
-
Is this live? |
Beta Was this translation helpful? Give feedback.
-
Dang. I was looking forward to an improved auth flow. |
Beta Was this translation helpful? Give feedback.
-
Would love to get an updated timeline for this, even if it's Q2/3/4 2025 |
Beta Was this translation helpful? Give feedback.
-
Will these custom api keys work for creating a rest api on an edge function and letting user authorize with an api key? |
Beta Was this translation helpful? Give feedback.
-
How can I manually generate the new API keys for an existing project? |
Beta Was this translation helpful? Give feedback.
-
Is there an updated timeline for the new keys, if not when can there be one? |
Beta Was this translation helpful? Give feedback.
-
Quick question: I have some migrations where I created a Do we just swap out the word Here is the sql: create table "public"."user" (
"id" uuid not null default gen_random_uuid(),
"created_at" timestamp with time zone not null default now(),
"email" text not null,
"first_name" text not null,
"last_name" text not null
);
alter table "public"."user" enable row level security;
CREATE UNIQUE INDEX user_pkey ON public."user" USING btree (id);
alter table "public"."user" add constraint "user_pkey" PRIMARY KEY using index "user_pkey";
grant delete on table "public"."user" to "anon";
grant insert on table "public"."user" to "anon";
grant references on table "public"."user" to "anon";
grant select on table "public"."user" to "anon";
grant trigger on table "public"."user" to "anon";
grant truncate on table "public"."user" to "anon";
grant update on table "public"."user" to "anon";
grant delete on table "public"."user" to "authenticated";
grant insert on table "public"."user" to "authenticated";
grant references on table "public"."user" to "authenticated";
grant select on table "public"."user" to "authenticated";
grant trigger on table "public"."user" to "authenticated";
grant truncate on table "public"."user" to "authenticated";
grant update on table "public"."user" to "authenticated";
grant delete on table "public"."user" to "service_role";
grant insert on table "public"."user" to "service_role";
grant references on table "public"."user" to "service_role";
grant select on table "public"."user" to "service_role";
grant trigger on table "public"."user" to "service_role";
grant truncate on table "public"."user" to "service_role";
grant update on table "public"."user" to "service_role"; |
Beta Was this translation helpful? Give feedback.
-
What's the plan for self-hosted via docker? Is it available there already? I did a quick scan but didn't see this in the docker files. |
Beta Was this translation helpful? Give feedback.
-
According to the FAQ:
I am using connection strings with Prisma. I just restored a project which was paused for inactivity and can no longer reach it from my application.
Also:
Has this policy changed? The connection instructions in the project show no change in the recommended setup for connecting with Prisma. |
Beta Was this translation helpful? Give feedback.
-
Updated timeline posted anywhere? |
Beta Was this translation helpful? Give feedback.
-
Has anything on this been actioned? |
Beta Was this translation helpful? Give feedback.
-
my current (old style) anon key has a start date of june 2025, can i migrate to new keys yet or how do i refresh the old one |
Beta Was this translation helpful? Give feedback.
-
Why must I pass both JWT token and anon API keys to access the PostgREST API? |
Beta Was this translation helpful? Give feedback.
-
@kangmingtay Will be be able to create multiple secret keys? It'll help with reducing downtime during key rotation. |
Beta Was this translation helpful? Give feedback.
-
Necesito ayuda 🆘 |
Beta Was this translation helpful? Give feedback.
-
Will we still be able to verify users in cloudflare workers (like we were doing with JWTs) without having to connect to supabase? If so a snippet of some kind would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
Initial commit |
Beta Was this translation helpful? Give feedback.
-
Can some create a video, for the common programming languages, c#, java, dart, js etc for the new api key method. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
any one easle face any issues with supabase dashboard management after implementing new keys? "Failed to delete user: |
Beta Was this translation helpful? Give feedback.
-
Hi. A question:
Now it requires the secret key. Is this intentional? |
Beta Was this translation helpful? Give feedback.
-
Hi having an issue where after creating a secret API key (and having legacy jwt secrets disabled), using it with the supabase client in the python SDK returns "Invalid API Key". This error disappears when reverting back to old service_role key. My Next app, however, only works with the new publishable API key, and authN fails when providing the old anon key. It seems others are having similar issues with authorization when using the new API keys. |
Beta Was this translation helpful? Give feedback.
-
Edge function call with new ES256 jwt tokens fails with "Legacy API keys are disabled" error. My setup
Additional things I tried:
What is the correct set up for Edge function then? I would still like to have the jwt key passed so that I can retrieve the user id ("sub") and make additional queries in the database. It appears re-enable the legacy JWT token solves the issue, but it does not appear to be recommended. I also do not know if there will be conflicts if both systems are present and which one will take priority. |
Beta Was this translation helpful? Give feedback.
-
My project currently using nextjs and I have followed the supabase SSR manual for authentication. I have public URL i use and an anon key. Can I replace the anon key with the publishable key and everything should work as is? |
Beta Was this translation helpful? Give feedback.
-
I am no longer able to generate types using
|
Beta Was this translation helpful? Give feedback.
-
With the recent switch to asymmetric JWTs and the new API key generation UI, it seems we can no longer generate tokens with custom roles. Previously, I used a script to sign JWTs with a custom role for backend workers: import { SignJWT } from 'jose'
const secret = new TextEncoder().encode(process.env.SUPABASE_JWT_SECRET)
const signedJwt = await new SignJWT({ role: role })
.setProtectedHeader({ alg: 'HS256' })
.setExpirationTime('10y')
.sign(secret) In the initial post of this discussion, it was announced:
However, it looks like this feature was removed before the final release (I noticed @hf edited the OP to remove this mention). Is there a timeline or plan to support assigning custom roles to secret API keys? This would be welcome to increase the security of some of our backend workflows. |
Beta Was this translation helpful? Give feedback.
-
Hi,
|
Beta Was this translation helpful? Give feedback.
-
Are publishable keys available on local studio now? |
Beta Was this translation helpful? Give feedback.
-
Can someone explain You will need to apply this option to functions you are protecting without it.? What are the steps needed to migrate the user-check step in an edge function? I'm creating a client with user privileges, then getting the user ID as follows, but I keep getting export function getSupabaseUserClient(request: Request): SupabaseClient {
const authorizationHeader: null | string =
request.headers.get('Authorization');
if (!authorizationHeader) {
throw new ApiError('Authorization header is not set.', 401);
}
return createClient(
Deno.env.get('SUPABASE_URL')!,
Deno.env.get('SUPABASE_ANON_KEY')!,
{
auth: { persistSession: false },
global: { headers: { Authorization: authorizationHeader } },
},
);
} export async function getUserId(
supabaseClient: SupabaseClient,
): Promise<string> {
const { data, error } = await supabaseClient.auth.getClaims();
if (error) {
throw error;
}
if (!data) {
throw new ApiError('User was not found.', 404);
}
return data.claims.sub;
} |
Beta Was this translation helpful? Give feedback.
-
Can we get some additional clarification on how this check is performed? I am using the supabase-js client in the Google Apps Script runtime environment and this error popped up when trying to switch from the old To be clear, this is not a browser environment, it is a server cloud-based runtime environment. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We’re changing the way API keys work in Supabase to improve your project’s security and developer experience. Refer to the timetable below for key dates and info on actions you may need to take in the future.
This change starts out as early preview and is opt-in. No action necessary until at least 1st November 2025. We strongly encourage you to give the new API keys a try!
What's the change?
These are the planned changes for the API keys:
anon
andservice_role
keys remain available for use.sb_publishable_...
can be used to replace theanon
key.sb_secret_...
. You can also choose not to have a secret key if you don’t need one. Secret keys replace theservice_role
key.anon
andservice_role
keys, as needed during the migration period.Summarized, there are 4 types of API keys that can now be used with Supabase. This chart should illustrate it better:
sb_publishable_...
sb_secret_...
anon
service_role
Timetable
New projects will automatically generate both new API keys and legacy API keys to help ease the transition.
Existing projects can continue to use the legacy API keys and can opt in to use the new API keys by manually generating them.
Feedback and issues seen in the early preview period to be resolved.
Projects restored from 1st November 2025 will no longer be restored with the legacy API keys.
New projects no longer have
anon
andservice_role
available for use.Why are we doing this?
Since the start of Supabase, the JWT-based
anon
andservice_role
keys were the right trade-off between simplicity and relative security for your project. Unfortunately they pose some real challenges in live applications, especially around rotation and security best practices.The main reasons for making this change are:
anon
(low privilege),service_role
(high privilege), andauthenticated
(issued by Supabase Auth) Postgres roles.Start using the new API keys
It’s easy to start using the new API keys. You can opt in in the Supabase dashboard. This will create the default publishable key and a single secret API key.
For the most part, you can substitute the
sb_publishable_...
andsb_secret_...
values anywhere you used theanon
andservice_role
keys respectively. They work roughly the same in terms of permissions and data access.You can initialize any version of the Supabase Client libraries with the new values without any additional changes, and we don't expect any backward compatibility issues.
Key differences to be aware of
We've redesigned how the Supabase hosted platform deals with API keys with a few key goals:
To achieve these, the new API keys have some subtle differences from
anon
andpublishable
:--no-verify-jwt
which means they can be called without knowing any API key. You will need to apply this option to functions you are protecting without it.Authorization
header. It is no longer possible to use a publishable or secret key inside theAuthorization
header — because they are not a JWT. Instead pass in the user’s JWT, or leave the header empty. For backward compatibility, it is only allowed if the value in the header exactly matches the value in theapikey
header.We believe these limitations are minor and not likely to impact even a single-digit percentage of existing customers. Should you find any additional limitation do not hesitate to bring it up in this discussion or via Supabase Support.
Beta Was this translation helpful? Give feedback.
All reactions