Repository navigation
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
We are trying to integrate Firebase Auth with our Supabase project which uses Edge Functions and Postgres, as this integration has been released recently. First, we were trying to test this integration out locally with the Supabase local containers (supabase start -x vector) running on a dev machine alongside the Firebase emulator (firebase emulators:start --import=firebase_local). Our client is a Flutter app that uses the supabase_flutter and firebase_auth libraries. When the Firebase user is signed in on our app and makes a request to our Edge Function endpoints running locally, we see this error output from the supabase functions serve logs:
TypeError: Key for the none algorithm must be of type CryptoKey. Received an instance of Uint8Array
at asymmetricTypeCheck (https://deno.land/x/[email protected]/lib/check_key_type.ts:14:11)
at checkKeyType (https://deno.land/x/[email protected]/lib/check_key_type.ts:39:5)
at flattenedVerify (https://deno.land/x/[email protected]/jws/flattened/verify.ts:78:3)
at compactVerify (https://deno.land/x/[email protected]/jws/compact/verify.ts:15:26)
at Module.jwtVerify (https://deno.land/x/[email protected]/jwt/verify.ts:5:26)
at verifyJWT (file:///root/index.ts:94:16)
at Object.handler (file:///root/index.ts:124:34)
at respond (ext:sb_core_main_js/js/http.js:197:38)
at handleHttp (ext:sb_core_main_js/js/http.js:131:5)
at eventLoopTick (ext:core/01_core.js:168:7)
When we run supabase functions serve --no-verify-jwt instead, we don't see that error being thrown by the middleware, but we see another error when our Functions endpoint executes the following lines of code:
const authHeader = req.headers.get('Authorization') ?? '';
console.log('Authorization Header:', authHeader);
const token = authHeader.replace('Bearer ', '');
const { data: userData, error: userError } = await supabaseClient.auth.getUser(token);
console.log('User Error:', userError);
AuthApiError: invalid JWT: unable to parse or verify signature, token signature is invalid: signing method none is invalid
at Me (https://esm.sh/@supabase/[email protected]/es2022/auth-js.mjs:3:7021)
at eventLoopTick (ext:core/01_core.js:168:7)
at async at (https://esm.sh/@supabase/[email protected]/es2022/auth-js.mjs:3:7864)
at async d (https://esm.sh/@supabase/[email protected]/es2022/auth-js.mjs:3:7583)
at async m._getUser (https://esm.sh/@supabase/[email protected]/es2022/auth-js.mjs:4:8517)
at async m.getUser (https://esm.sh/@supabase/[email protected]/es2022/auth-js.mjs:4:8373)
at async file:///Users/ggs_hy/Documents/Projects/good_game_sports/supabase/functions/get-tournaments/index.ts:36:48
at async Object.handler (file:///Users/ggs_hy/Documents/Projects/good_game_sports/supabase/functions/_shared/utils/api-helpers.ts:40:24)
at async respond (ext:sb_core_main_js/js/http.js:197:14) {
__isAuthError: true,
name: "AuthApiError",
status: 403,
code: "bad_jwt"
}
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Set up Firebase emulator as per this guide
- Make sure firebase.json has this property:
{
...
"emulators": {
"auth": {
"port": 9099,
"host": "0.0.0.0"
},
"firestore": {
"port": 8080,
"host": "0.0.0.0"
},
"ui": {
"enabled": true,
"port": 4000,
"host": "0.0.0.0"
},
"singleProjectMode": true
}
}
- Start firebase emulator by running
firebase emulators:start - Make sure supabase config.toml has these lines:
[auth.third_party.firebase]
enabled = true
project_id = "<our-project-id>"
- In a new terminal, run
supabase start -x vector, followed bysupabase functions serve - In Flutter app, make sure that the
main()entrypoint has these lines of code:
final localhostIP = kIsWeb ? 'http://localhost:54321' : Platform.isAndroid ? 'http://10.0.2.2:54321' : 'http://localhost:54321';
await Supabase.initialize(
url: localhostIP,
anonKey: '<our-anon-key>',
accessToken: () async {
final token = await FirebaseAuth.instance.currentUser?.getIdToken();
return token;
},
);
FirebaseAuth.instance.useAuthEmulator('localhost', 9099);
- In Flutter app, create a new account w/ Firebase Auth library and log into that account
- From Flutter app, make a request to any Supabase Edge Functions endpoint, and the error will repro.
Expected behavior
We expect to be able to test the Firebase Auth integration with a locally running instance of Firebase, and for the Firebase Auth JWT to be parsed without any errors.
System information
- OS: Windows 11 for supabase local backend, Android 15 emulator for Flutter client
- Browser (if applies) N/A
- Version of supabase cli: 2.20.12
- Version of supabase-js: 2.45.4
- Version of Node.js: v20.16.0
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity