-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow multiple openauth providers #23
Comments
I'm open to supporting multiple OAuth providers, but I'm worried that problems will arise that may not have a definitive solution. For example:
I can think of different use-cases that would require different solutions to these problems. I guess my question is, is there a single best way to do this? |
After some thought, here is my proposal for this feature. I can think of two possible approaches to this, which I'm calling "Plan A" and "Plan B". Plan A
This has the following benefits:
This plan has the following drawbacks:
Plan BAn alternative plan would be to use
This plan has the following benefits:
But this plan has worse drawbacks in my opinion:
I can see some benefit to "Plan A", and I hate "Plan B". I'll leave this open for a while to see if anyone has any comments before I get started. |
I used this method in the past to hook up multiple providers on one account and it worked really well: http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/ |
Plan C, leave it up to the developer? I've always used Omniauth to achieve multiple provider auth. Omniauth cleans up the authentication strategies, but does not enforce any particular way of storing the provider data. That way the developer gets to choose what makes sense for their implementation. Personally, I'm going to implement what you described in Plan B, one way or another, because that's how my application has to work. That said, I've also worked on apps that only support Facebook auth, so leaving things the way you have them would be fine for that. In short, I would prefer to implement the provider storage myself, in whatever models make sense for the app I'm building. |
@jonlemmon - I'm having trouble accessing that link. Can you double-check that it's correct? @asoules - I definitely don't want to do anything that would complicate things for developers. I'm curious - do you think this gem is doing anything now that makes it difficult to implement multiple provider auth? @UrbanViking - I'm not sure if I understand what you're suggesting in your second comment. Can you please clarify? |
@lynndylanhurley perhaps I'm mistaken, but it seems to make the assumption that a single provider was used to sign up, and the details are stored in User#provider and User#uid. I tried to leave these fields out, but I hit validation errors when devise_token_auth tried to validate that no other users existed with the same provider and uid. The OmniauthCallbacksController also assumes that User#provider and uid will be used. This makes it difficult to connect with multiple providers out of the box. |
I removed my previous comment to make myself more clear. I suggest staying with the single auth provider concept - email or OAuth provider - and remove the User Info attributes including the email attribute. It would make Devise-Token-Auth simple to use (and understand) for beginners and more experience can override the default controllers and create additional tables to add multiple auth providers and user info as needed. It seems messy to have some user info attributes in user (authentication) table and particularly the email attribute when email address is also stored in the uid attribute. |
@UrbanViking - thanks again for your comments.
I expect to be able to perform these basic operations without any trouble:
With the current implementation, these operations are trivial. But if the Also, you can override the default implementation as you like.
"Email" is just another provider, where the unique id ( |
@asoules - I may have a proposal to solve that issue, but I'll need time to work it out. I'll post back ASAP. |
Apologies, I offended you with the "messy", but it is not clear that UID column can be an email address when you also have Email column. The UID and PROVIDER need to form an unique key together. All User Info columns should be optional including EMAIL. Don't you need a SECRET column on user table for e.g. Facebook authentication? |
@UrbanViking - no offense taken! I appreciate your feedback 😃
That is how it works currently.
The secret is defined in the provider's initializer. There are instructions here. |
@lynndylanhurley If EMAIL is not used for authentication, perhaps it should be listed under User Info instead of Database Authentication in devise_token_auth_create_users.rb migration file :-) |
@UrbanViking - that makes sense. Can you please post that as a new issue? I'd like to steer this issue back to multi-user authentication if possible 🎃 |
@lynndylanhurley Was there any progress made with this? :) |
fwiw, I've just implemented my own single-account login using any account (email+password, facebook and Google). The single account ID is the email. Here's the changes I had to make in order to get this to work, mostly overriding an action in a controller (from devise_token_auth) just to drop some hard-coded things like the Here's the change in my project. |
I agree with @asoules I am trying to implement multiple providers in reference to https://github.com/intridea/omniauth/wiki/Managing-Multiple-Providers (I think this is plan B @lynndylanhurley ) but I have to override so many controllers and concern (anything which assumes user has provider and uid). I would really appreciate it if the gem is flexible enough to allow multiple providers. |
@mkhatib One problem I see with using email as the unique account ID is that users might not use the same email address across their different OAuth provider accounts. Some providers also don't provide email (Twitter for example). Your solution appears to work, but to me, it doesn't seem nearly as robust as Plan B suggested by @lynndylanhurley. @phs1919, were you able to successfully implement that? I'm planning on doing something similar, but I'm a bit wary of overriding so much code. |
@frankjwu i've done something similar with https://github.com/intridea/omniauth/wiki/Managing-Multiple-Providers But i agree plan B is more robust, allow users to associate with a primary account |
@harmoney-justins What do you use for a User's UID and provider? (assuming you now store that information in the Identities table) |
@justinsoong I might be missing something, but that looks like standard Devise and not DeviseTokenAuth? The problem I was referring to earlier is that DeviseTokenAuth uses the |
If anyone comes across this issue, would be good to get feedback on PR #453 to see if that would solve your problems. |
I made some quick changes on https://github.com/wangzuo/devise_token_auth for multiple provider support |
In my app, I'm using a seperate model for openauth keys so that a user can connect with multiple providers. Will this be something that you'll be supporting down the road?
The text was updated successfully, but these errors were encountered: