cachapa / firedart

A dart-native implementation of the Firebase Auth and Firestore SDKs
https://pub.dev/packages/firedart
Apache License 2.0
174 stars 62 forks source link

feat: add option to use application default auth #97

Closed Kirpal closed 1 year ago

Kirpal commented 1 year ago

I added the option to use application default auth to authenticate instead of firebase auth. This allows you to use it on the backend with the same permissions as the firebase admin sdk.

cachapa commented 1 year ago

Hey, thanks for the contribution.

Can you explain a bit more in detail what exactly this is doing? I haven't used Firebase for a while and my knowledge of the platform is slowly becoming rusty and outdated.

Please note that your changes are currently breaking the tests. Actually it'd be great if you could add tests to cover your changes as well.

Kirpal commented 1 year ago

Hi, I fixed the tests and added test cases using the new authenticator.

The reason for this change is to allow firedart to act like the firebase admin SDK on a dart backend, basically allowing it to circumvent database rules and other limitations. Rather than authenticating as a user with firebase auth, we can authenticate as an administrator on the project, with the same permissions as if you were using the firebase website console directly. This is useful when running firedart on a server environment, especially on Google Cloud.

More about Application Default Auth here: https://cloud.google.com/docs/authentication/application-default-credentials

cachapa commented 1 year ago

I marked the PR as draft because I was waiting for your comments. Please remove it when/if you're ready for review.

I'll review the PR once you're ready.

cachapa commented 1 year ago

Hey, sorry for taking so long to review.

Your patch seems good, I'm ready to merge, but I think the tests could have been structured better: by moving all the tests into a separate method you could then pass the auth as an argument and avoid the duplicate code.

I don't want to force you to do more work after my delay though so let me know if you'd like to do that yourself, otherwise I'll just aprove this PR and cleanup later.