Created
August 28, 2015 06:18
-
-
Save cyberfox/44de7f5f70b5e8916425 to your computer and use it in GitHub Desktop.
Revisions
-
cyberfox created this gist
Aug 28, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ require 'sinatra' require 'omniauth-twitter' require 'omniauth-salesforce' configure do enable :sessions end helpers do def h(text) Rack::Utils.escape_html(text) end end use OmniAuth::Builder do provider :twitter, ENV['TWITTER_CONSUMER_KEY'], ENV['TWITTER_CONSUMER_SECRET'] provider :salesforce, ENV['SALESFORCE_CONSUMER_KEY'], ENV['SALESFORCE_CONSUMER_SECRET'] end OmniAuth.config.full_host = "https://auth.vulpine.com" get '/test' do erb("<%= h 'Succ<ess>ful.'%>") end get '/login/twitter' do redirect to('/auth/twitter') end get '/login' do redirect to('/auth/salesforce') end get '/auth/:provider/callback' do puts env['omniauth.auth'].inspect session[:user] = env['omniauth.auth']['raw_info'] session[:uid] = env['omniauth.auth']['uid'] session[:logged_in] = true erb <<-EOHTML <!DOCTYPE html> <html> <head> <title>Welcome!</title> </head> <body> <h1>Hello <%= h env['omniauth.auth']['info']['name'] %>!</h1> <br/> <%= h env['omniauth.auth'].inspect %> <br/> <br/> From provider: #{env['omniauth.auth']['provider']} vs. #{params[:provider]} </body> </html> EOHTML end get '/auth/failure' do params[:message] end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ source 'https://www.rubygems.org' gem 'sinatra' gem 'omniauth-twitter' gem 'omniauth-salesforce'