Skip to content

Commit

Permalink
Simple google apps auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
saterus committed Apr 19, 2012
1 parent b7528e9 commit ed09b10
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -8,6 +8,7 @@ gem 'rails'
gem 'haml-rails'
gem 'jquery-rails'
gem 'twitter-bootstrap-rails'
gem 'omniauth-openid'

gem 'elo'

Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Expand Up @@ -47,6 +47,7 @@ GEM
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
hashie (1.2.0)
heroku (2.24.1)
launchy (>= 0.3.2)
netrc (~> 0.7.1)
Expand Down Expand Up @@ -76,6 +77,12 @@ GEM
mime-types (1.18)
multi_json (1.2.0)
netrc (0.7.1)
omniauth (1.1.0)
hashie (~> 1.2)
rack
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
pg (0.13.2)
polyglot (0.3.3)
pry (0.9.8.4)
Expand All @@ -95,6 +102,9 @@ GEM
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
Expand Down Expand Up @@ -132,6 +142,7 @@ GEM
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.9.0)
ruby-openid (2.1.8)
rubyzip (0.9.7)
sass (3.1.15)
sass-rails (3.2.5)
Expand Down Expand Up @@ -174,6 +185,7 @@ DEPENDENCIES
haml-rails
heroku
jquery-rails
omniauth-openid
pg
pry
pry-doc
Expand Down
13 changes: 13 additions & 0 deletions app/controllers/session_controller.rb
@@ -0,0 +1,13 @@
class SessionController < ApplicationController

def create
email = request.env['omniauth.auth'].info.to_hash['email']
if email =~ /@(the)?edgecase.com\Z/
flash.notice = "Authorized as #{email}"
else
flash.alert = "#{email} not authorized!"
end
redirect_to request.env['omniauth.origin'] || root_path
end

end
3 changes: 3 additions & 0 deletions config/initializers/omniauth.rb
@@ -0,0 +1,3 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :openid, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
end
8 changes: 5 additions & 3 deletions config/routes.rb
@@ -1,9 +1,11 @@
Pong::Application.routes.draw do


match '/auth/google/callback' => 'session#create'

resources :matches
resources :players

match '/distribution' => 'players#distribution', :as => 'distribution'

root to: 'players#rankings'
end

0 comments on commit ed09b10

Please sign in to comment.