Module: Sinatra::GoogleAuth

Defined in:
lib/sinatra/google-auth.rb,
lib/sinatra/google-auth/version.rb

Defined Under Namespace

Modules: Helpers Classes: Middleware

Constant Summary collapse

VERSION =
'0.0.8'

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/sinatra/google-auth.rb', line 49

def self.registered(app)
  raise "Must supply ENV var GOOGLE_AUTH_URL" unless ENV['GOOGLE_AUTH_URL']
  app.helpers GoogleAuth::Helpers
  app.use ::Rack::Session::Cookie, :secret => secret
  app.use ::OmniAuth::Strategies::OpenID, :name => "google", :identifier => ENV['GOOGLE_AUTH_URL']
  app.set :absolute_redirect, false

  app.get "/auth/:provider/callback" do
    handle_authentication_callback
  end

  app.post "/auth/:provider/callback" do
    handle_authentication_callback
  end
end

.secretObject



45
46
47
# File 'lib/sinatra/google-auth.rb', line 45

def self.secret
  ENV['SESSION_SECRET'] || ENV['SECURE_KEY'] || 'please change me'
end