Reputation: 692
I have read Firebase docs, a lot of articles and stackoverflow posting without finding anything that talks about using Firebase Gmail based authentication to access a Firebase firestore collection. Most articles have the firestore in test mode with open access or they are using Firebase's email/password Auth and a collection in firestore. The Firebase's email/password Auth with email/password shows the following rule.
allow read, write: if request.auth.uid = !null.
This doesn't work, because I can't pass the uid (Gmail doesn't have it) when requesting the data from firestore.
Ideally, I would like to use the JWT returned from the Firebase Gmail authentication and sent it to Firestore request. Again, I couldn't find a single example of Firebase firestore using a token.
If there is an article, docs or just experience, please let me know.
Thanks in advance
Upvotes: 1
Views: 231
Reputation: 317808
There's no way to manually "send" a JWT with a query. When using the Firebase client SDKs in your app, authentication tokens can only be sent automatically along with a query if you're also using Firebase Authentication to authenticate the user. If you're not using Firebase Auth, then there will be no token that identifies the user, which means you can't use request.auth
at all in your security rules.
Firebase Authentication does support Google as an authentication provider, so you should be able to use the two together in your app if you want write effective security rules.
Upvotes: 1