I'm building an authentication feature and it will also be making use of Firebase which means I should also implement the so called Firebase authentication. On the other hand I would not like the app to be limited to that type of authentication only and would want it to support other types. All in all, it seems like using different authentication strategies is what I am looking for.
I want to inject AuthService into the auth component and then implement all types of auth methods that are required. AuthService should implement IAuthService interface, the same interface must be implemented by the strategies. Interface should define the following main methods: signIn, signUp, signOut.
Let's say I can create FirebaseAuthStrategy, but it is possible to login using social media (e.g. Google+, Facebook, Twitter etc), it's also possible to sign in with popup as well as without it. If I start creating such strategies, there will be too many of them (even though I think it's possible to make the code dry through inheritance, that will be a long chain), so I will end up with FirebaseAuthWithGoogleWithPopup, FirebaseAuthWithGoogleWithoutPopup, FirebaseAuthWithEmailAndPasswordWithoutPopup and so on which looks pretty stupid. I could pass a provider (google, twitter, etc) as a parameter though but it doesn't solve the overall issue.
What I would like to know is how this issue is normally handled in big interprise apps.
Aucun commentaire:
Enregistrer un commentaire