Omniauth

首先选择你的身份验证策略并将其添加到你的 Gemfile。你可以在此处找到策略列表: https//github.com/intridea/omniauth/wiki/List-of-Strategies

gem 'omniauth-github', :github => 'intridea/omniauth-github'
gem 'omniauth-openid', :github => 'intridea/omniauth-openid'

你可以将其添加到 rails 中间件,如下所示:

Rails.application.config.middleware.use OmniAuth::Builder do
  require 'openid/store/filesystem' 
  provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET']
  provider :openid, :store => OpenID::Store::Filesystem.new('/tmp')
end

默认情况下,OmniAuth 会将/auth/:provider 添加到你的路线中,你可以从这些路径开始。

默认情况下,如果出现故障,omniauth 将重定向到/auth/failure