step-up-labs / firebase-authentication-dotnet

C# library for Firebase Authentication
MIT License
376 stars 129 forks source link

Enable multitenancy in Firebase.Auth project #218

Open GiampaoloGabba opened 3 months ago

GiampaoloGabba commented 3 months ago

I'm opening this draft to know if you are interested in support multitenancy. I'have upated only the Firebase.Auth project, i'm not using UI and also dont have the winui3 and uwp sdk installed.

There are not "strict" breaking changes: the tenantId is an optional string. But even if its optional, people updating the nuget will be required to recompile their project (but this should not be a problem: if you are updating a nuget, then you'll likely recompile your project @ 😄 )

Some additional tests will be required, but for now everything seems working great (already using it in my app without problems).

For reference, i took the requests that have the tenantId field in input from here: https://developers.google.com/resources/api-libraries/documentation/identitytoolkit/v3/python/latest/identitytoolkit_v3.relyingparty.html#verifyAssertion

https://cloud.google.com/identity-platform/docs/use-rest-api?hl=it#section-confirm-email-verification

bezysoftware commented 3 months ago

I had a quick look at the official firebase samples and they do not have the tentantId in their method signatures - instead they populate the tenantId in their version of our config object: firebase.auth().tenantId = '...'

I wonder if this solution would make the code more clean? By adding it to FirebaseAuthConfig it would also minimize the changes needed to FirebaseUI, which uses FirebaseUIConfig which in turn directly inherits from FirebaseAuthConfig.

So in other words add the TenantId to FirebaseAuthConfig, revert the method signatures in FirebaseAuthClient and use the new property from config.

What do you think?