module Sinatra::GAuth
Constants
- VERSION
Public Class Methods
registered(app)
click to toggle source
# 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