FirebaseExtended / experimental-extensions

🧪 A laboratory for new extensions created by Firebase
https://firebase.google.com/docs/extensions
Apache License 2.0
244 stars 41 forks source link

firebase-auth-claims extension does not run against the emulator #97

Closed wstrange closed 1 year ago

wstrange commented 2 years ago

Expected Behavior

The firebase-auth-claims sets custom claims using the authentication emulator.

Actual Behavior

The firestore user_claims document is created in the emulator. I can see the user_claims object and add attributes.

The extension attempts to update claims in the cloud instance, not the local auth emulator. I can validate this by using a uid from the cloud. When the local firestore emulator user_claims is written with a cloud uid, it updates the cloud ok - no error.

When I attempt to use a local auth emulator id, I get " error: FirebaseAuthError: There is no user record corresponding to the provided identifier". This uid does not exist in the cloud. I understand the error - but not how to get the extension to use the auth emulator.

My other functions work fine in the emulator, and clearly the extension is being triggered by a write to the firestore emulator instance. It's just not going against the local auth emulator.

I also get a "'firebase-admin' dependency is below version 9.3.0," It looks like the extension needs to be updated?

Steps to Reproduce the Problem

What happened? How can we make the problem occur?

Install the extension using the cli Add a doc to user_claims with the id of an existing user in the authentication emulator.

Specifications

danbaechtold commented 1 year ago

Also, the emulator crashes when the extension is invoked:

!  The Cloud Functions emulator requires the module "firebase-admin" to be installed. This package is in your package.json, but it's not available. You probably need to run "npm install" in your functions directory.
i  functions: Your functions could not be parsed due to an issue with your node_modules (see above)
!  Error: Cannot find module 'firebase-functions'
Require stack:
- C:\Users\dan\.cache\firebase\extensions\firebase\firestore-auth-claims@0.1.1\functions\lib\index.js
danbaechtold commented 1 year ago

I was able to fix the issue above by running npm i in my .cache directory.

However the extension is outdated and needs to have it's dependencies updated.

From emulator logs:

The Firebase Authentication emulator is running, but your 'firebase-admin' dependency is below version 9.3.0, so calls to Firebase Authentication will affect production.

I've tried to update them to the latest verisons, but building then failed..

@mbleigh Could you release a new version (with updated dependecies) please?

rubenheymans commented 1 year ago

why is this still an experimental extension though after all these years? They created a new extensions website etc., but this repo is inactive

ian-sayles commented 1 year ago

You not only one who can't understand why some of these have not been transferred to the new web site, they did transfer some, but I have been using this on an app for over a year now with no issues, and thought by now it would have been transferred over.

cabljac commented 1 year ago

Hey there, sorry - I planned to work on this but other work got in the way.

I've opened a PR to update dependencies here https://github.com/FirebaseExtended/experimental-extensions/pull/122

I'll try and look into the emulator issues next.

rubenheymans commented 1 year ago

Hey there, sorry - I planned to work on this but other work got in the way.

I've opened a PR to update dependencies here #122

I'll try and look into the emulator issues next.

Just to be sure we're not blaming you @cabljac , but it would be nice if Firebase could put some more recourses into it

cabljac commented 1 year ago

no worries :D All the extensions need some dependency care, im going to try and work through them.

I got this extension working with the emulator today, i've updated that PR.

ian-sayles commented 1 year ago

Hi @cabljac thanks for updating the dependency, will you be merging the PR back into the main branch so the extension can be updated in the firebase console?