Adding external providers to sorcery

1.8k Views Asked by At

I have an app with authentication, which has been done with devise and used omniauth to sign in from various providers (including vk.com, google, twitter and so on). Everything seemed working well, except that I needed to include a separate gem for every provider.

Now I decided to make that authentication much lighter and add some logging, so I decided to move from devise to sorcery. But now I have a problem with external providers, 'cause the gem has only few (no vk.com or yahoo, which I do need).

I tried to understand the code of the externalproviders to add my own just alike, but it seems a little bit too complicated for me. Is there any easier way around?

2

There are 2 best solutions below

1
On BEST ANSWER

Just in case someone finds this question while looking for a similar answer, Sorcery does now include External authentication for most major logins. See:

https://github.com/Sorcery/sorcery/wiki/External

In your rails app after installing the External module you'll have a file: config/initializers/sorcery.rb. In it there will be example code for most providers.

1
On

I don't think you're going to find an easy solution to this.

I ran into this problem on the last app I worked on. I ended up just going with both Sorcery and Omniauth. I integrated them together in the Users model and Sessions controller. Sorcery's external provider stuff doesn't seem to be kept up to date.

In the end though, if I had to do it again I'd probably just do the authentication from scratch. Sorcery is nice, but it doesn't seem like it provides enough to warrant an additional dependency.

If authentication from scratch is the way you end up going, you can check out these resources:

  1. https://github.com/NoamB/sorcery/tree/master/lib
  2. https://github.com/railscasts/250-authentication-from-scratch-revised