quarkiverse / quarkus-google-cloud-services

Google Cloud Services Quarkus Extensions
https://docs.quarkiverse.io/quarkus-google-cloud-services/main/index.html
Apache License 2.0
54 stars 33 forks source link

Emulator auth when using both PubSub and FirebaseAdmin #690

Open jfbenckhuijsen opened 2 weeks ago

jfbenckhuijsen commented 2 weeks ago

Hey @loicmathieu,

I think I've run into an issue when using both pubsub and the FirebaseAdmin module when using the emulator.

As per https://cloud.google.com/pubsub/docs/emulator#pubsub-emulator-java for PubSub we need to use the "NoCredentials" class when connecting to the emulator

As per https://stackoverflow.com/questions/63781560/connecting-to-firestore-emulator-from-java-admin-sdk you need to use the EmulatorCredentials when connecting to the emulator.

As per https://docs.quarkiverse.io/quarkus-google-cloud-services/main/#emulators we can configure both Credentials as a CDI bean and a CredentialsProvider as CDI bean.

You can configure the "Credentials" to be the EmulatorCredentials and the CredentialsProvider to be the NoCredentialsProvider, and then it seems to work, but this is hardly intuitive for a user of the library (and is not documented).

I'd propose we add config options like we did for the Firestore situation to have the library automatically configure the right credentials for the emulator to use and avoid the hassle of needing to create that mock bean.

We can easily achieve this by using Instance to retrieve it at runtime if the emulator is switched off I'd say?

Lemme know what you think, can create the PR of course.

loicmathieu commented 2 weeks ago

Well, this is annoying I agree, and the blame is upsteam ;)

But yes, if you can provide something that ease these cases, I'll be happy to review it

jfbenckhuijsen commented 2 days ago

Initial version #705

jfbenckhuijsen commented 2 days ago

Need to look into the Firebase Admin version still btw