-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(auth, multi-tenant): add multi-tenant (tenantID) support #5004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/invertase/react-native-firebase/BsJEQQhcE4zboGY5Xa3RoXs4YfFi |
Xianning Liu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Codecov Report
@@ Coverage Diff @@
## master #5004 +/- ##
==========================================
- Coverage 89.09% 88.74% -0.35%
==========================================
Files 109 105 -4
Lines 3721 3488 -233
Branches 348 0 -348
==========================================
- Hits 3315 3095 -220
- Misses 365 393 +28
+ Partials 41 0 -41 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xianlinbox thank you so much for this! We have had some interest in it, but have not had time to implement it.
I made some comments about the shape of the API as I think it can be fully synchronous based on the underlying native APIs being synchronous.
Also I made some grammar comments but please understand I know how tough it is to speak multiple languages (you should hear me speak Spanish...), I hope you don't mind the suggestions
Finally, it appears the User object also has a read-only tenantId property that you could easily expose, do you think you could add that? It is apparently related to the app tenantId but could be independent (you can change app tenantId after users are associated with another tenantId, and I think multi-tenant users might need to know the user's tenantId)
https://firebase.google.com/docs/reference/swift/firebaseauth/api/reference/Classes/User#tenantid
https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseUser#public-abstract-string-gettenantid
I think user.tenantId may already be populated in the current user naturally, so it may just be a matter of copying it to the JS object from native and adding it to the types? Worst case, as a user is returned from native methods, you may need to call the tenantId getter in native code, then return it with the rest of the user information?
Finally, I really really appreciate that you added test code along with the change. That helps us so much.
Cheers
Maintainer note: I verified that the multi-tenant support was added prior to our current native SDK minimum, this should be good to merge as feature release / non-breaking change once it is in shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested a different wording of the documentation a little bit to explain why null might be returned, I will commit that one
The only other question I have is about this:
Finally, it appears the User object also has a read-only tenantId property that you could easily expose, do you think you could add that? It is apparently related to the app tenantId but could be independent (you can change app tenantId after users are associated with another tenantId, and I think multi-tenant users might need to know the user's tenantId)
https://firebase.google.com/docs/reference/swift/firebaseauth/api/reference/Classes/User#tenantid
https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseUser#public-abstract-string-gettenantidI think user.tenantId may already be populated in the current user naturally, so it may just be a matter of copying it to the JS object from native and adding it to the types? Worst case, as a user is returned from native methods, you may need to call the tenantId getter in native code, then return it with the rest of the user information?
Oh - and the CLA is not signed yet - we will need the CLA signed (#5004 (comment)), it can merge now or if you have time to add user.tenantId we can merge after that, thanks @xianlinbox ! |
Thanks for the feedbacks and correct wording. I have clicked the link and signed the CLA. but I don't know why the PR didn't reflect that. |
per the comment above it is typically when commit email address is different than github email address, and you have not associated the commit email address with your github account - this happens for some people
|
…ve-firebase into support-set-tenant
@mikehardy as I need to updated the commit author to correct my email address, so I created a new PR (#5019) for this change. the code is same as this one. Can we move to that PR? |
Description
When I working on the firebase auth, I found I can't set tenant id which is quite critical for working with Google Identity platform. In the repository discussion channel. there are 2 questions related with this also.
Then I checked the Firebase iOS SDK, which actually provided tenantId for user to set it. So I created this PR to open this capability to React native Lib users.
Related issues
No
Release Summary
Support set tenant it in Firebase auth module.
Checklist
Android
iOS
e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
Test Plan
yarn tests:jest
Test Suites: 8 passed, 8 total
Tests: 1 skipped, 96 passed, 97 total
Snapshots: 0 total
Time: 20.6 s
Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on Twitter