Module: Sinatra::GAuth
- Defined in:
- lib/sinatra/g_auth.rb,
lib/sinatra/g_auth/version.rb
Defined Under Namespace
Modules: Helpers
Constant Summary collapse
- VERSION =
"0.0.5"
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sinatra/g_auth.rb', line 14 def self.registered(app) app.helpers GAuth::Helpers app.enable :sessions app.set :gauth_domain, 'gmail.com' app.set :gauth_redirect, '/' app.set :gauth_tmp_dir, '/tmp' app.set :gauth_openid_store, OpenID::Store::Filesystem.new(app.settings.gauth_tmp_dir) app.use OmniAuth::Builder do provider :google_apps, store: app.settings.gauth_openid_store, name: 'g', domain: app.settings.gauth_domain end app.post '/auth/g/callback' do if auth = request.env['omniauth.auth'] session[:_gauth] = { id: auth['uid'], name: auth['info']['name'], email: auth['info']['email'] } redirect app.settings.gauth_redirect else halt 401, 'Authorization Failed.' end end end |