Skip to content

Instantly share code, notes, and snippets.

@kjmkznr
Created June 27, 2011 14:34
Show Gist options
  • Save kjmkznr/1048969 to your computer and use it in GitHub Desktop.
Save kjmkznr/1048969 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'sinatra'
require 'omniauth'
require 'openid/store/filesystem'
require 'openid/fetchers'
OpenID.fetcher.ca_file = '/etc/ssl/certs/ca-certificates.crt'
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :open_id , OpenID::Store::Filesystem.new('/tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
end
#### Routes
get '/' do
<<-HTML
<a href='/auth/google'>Sign in with Google</a>
HTML
end
post '/auth/:name/callback' do
auth = request.env['omniauth.auth']
auth['user_info']['name']
end
get '/auth/failure' do
"Authentication Failed"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment