Is it possible to use Omniauth with Devise-JWT?

倾然丶 夕夏残阳落幕 提交于 2020-03-23 08:04:11

问题


I have Devise and Devise-JWT configured and working for a React single page application using good old email and password. Now, I'd like my users to be able to log in using Facebook/Google/Twitter, etc. Is Omniauth the way to go?

I have Omniauth sort of working with the Developer strategy and I wrote a method that generates the bearer token (I think):

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def developer
    @user = User.from_omniauth(request.env["omniauth.auth"], current_tenant)

    if @user.persisted?
      sign_in @user, event: :authentication #this will throw if @user is not activated
      token = Warden::JWTAuth::UserEncoder.new.call(@user, :user, nil).to_s
      redirect_to # Now what?

I'm unsure about what would be the next step, passing the token to the frontend as a URL parameter? That feels kinda risky security-wise, isn't it? This leads me to believe that maybe I'm pushing in the wrong direction here. Am I? How should this be done?

来源:https://stackoverflow.com/questions/60572711/is-it-possible-to-use-omniauth-with-devise-jwt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!