sinatra_omniauth 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Gemfile +10 -6
  2. data/Gemfile.lock +41 -21
  3. data/VERSION +1 -1
  4. data/config.ru +10 -7
  5. data/css/auth.css +3 -0
  6. data/{public/images → images}/authbuttons/aol_128.png +0 -0
  7. data/{public/images → images}/authbuttons/aol_256.png +0 -0
  8. data/{public/images → images}/authbuttons/aol_32.png +0 -0
  9. data/{public/images → images}/authbuttons/aol_64.png +0 -0
  10. data/{public/images → images}/authbuttons/basecamp_128.png +0 -0
  11. data/{public/images → images}/authbuttons/basecamp_256.png +0 -0
  12. data/{public/images → images}/authbuttons/basecamp_32.png +0 -0
  13. data/{public/images → images}/authbuttons/basecamp_64.png +0 -0
  14. data/{public/images → images}/authbuttons/campfire_128.png +0 -0
  15. data/{public/images → images}/authbuttons/campfire_256.png +0 -0
  16. data/{public/images → images}/authbuttons/campfire_32.png +0 -0
  17. data/{public/images → images}/authbuttons/campfire_64.png +0 -0
  18. data/{public/images → images}/authbuttons/facebook_128.png +0 -0
  19. data/{public/images → images}/authbuttons/facebook_256.png +0 -0
  20. data/{public/images → images}/authbuttons/facebook_32.png +0 -0
  21. data/{public/images → images}/authbuttons/facebook_64.png +0 -0
  22. data/{public/images → images}/authbuttons/github_128.png +0 -0
  23. data/{public/images → images}/authbuttons/github_256.png +0 -0
  24. data/{public/images → images}/authbuttons/github_32.png +0 -0
  25. data/{public/images → images}/authbuttons/github_64.png +0 -0
  26. data/{public/images → images}/authbuttons/google_128.png +0 -0
  27. data/{public/images → images}/authbuttons/google_256.png +0 -0
  28. data/{public/images → images}/authbuttons/google_32.png +0 -0
  29. data/{public/images → images}/authbuttons/google_64.png +0 -0
  30. data/{public/images → images}/authbuttons/linkedin_128.png +0 -0
  31. data/{public/images → images}/authbuttons/linkedin_256.png +0 -0
  32. data/{public/images → images}/authbuttons/linkedin_32.png +0 -0
  33. data/{public/images → images}/authbuttons/linkedin_64.png +0 -0
  34. data/{public/images → images}/authbuttons/myspace_128.png +0 -0
  35. data/{public/images → images}/authbuttons/myspace_256.png +0 -0
  36. data/{public/images → images}/authbuttons/myspace_32.png +0 -0
  37. data/{public/images → images}/authbuttons/myspace_64.png +0 -0
  38. data/{public/images → images}/authbuttons/openid_128.png +0 -0
  39. data/{public/images → images}/authbuttons/openid_256.png +0 -0
  40. data/{public/images → images}/authbuttons/openid_32.png +0 -0
  41. data/{public/images → images}/authbuttons/openid_64.png +0 -0
  42. data/{public/images → images}/authbuttons/presently_128.png +0 -0
  43. data/{public/images → images}/authbuttons/presently_256.png +0 -0
  44. data/{public/images → images}/authbuttons/presently_32.png +0 -0
  45. data/{public/images → images}/authbuttons/presently_64.png +0 -0
  46. data/{public/images → images}/authbuttons/twitter_128.png +0 -0
  47. data/{public/images → images}/authbuttons/twitter_256.png +0 -0
  48. data/{public/images → images}/authbuttons/twitter_32.png +0 -0
  49. data/{public/images → images}/authbuttons/twitter_64.png +0 -0
  50. data/{public/images → images}/authbuttons/yahoo_128.png +0 -0
  51. data/{public/images → images}/authbuttons/yahoo_256.png +0 -0
  52. data/{public/images → images}/authbuttons/yahoo_32.png +0 -0
  53. data/{public/images → images}/authbuttons/yahoo_64.png +0 -0
  54. data/lib/sinatra/omniauth.rb +26 -13
  55. data/models/authentication.rb +8 -5
  56. data/models/user.rb +3 -5
  57. data/omniauth.yml +0 -4
  58. data/sinatra_omniauth.gemspec +65 -56
  59. data/views/auth.haml +22 -14
  60. metadata +123 -66
  61. data/lib/models/authorization.rb +0 -16
  62. data/lib/models/user.rb +0 -14
  63. data/public/css/omniauth.css +0 -34
data/Gemfile CHANGED
@@ -1,17 +1,21 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gem 'sinatra'
4
- gem 'omniauth'
4
+ gem 'omniauth', '~> 0.2.2'
5
5
  gem 'dm-core'
6
6
  gem 'dm-migrations'
7
7
  #gem 'dm-sqlite-adapter'
8
8
  gem 'dm-postgres-adapter'
9
9
  gem 'sqlite3'
10
10
  gem 'rack-flash'
11
+ gem 'uuidtools'
12
+ gem 'haml', '>=3.1.1'
11
13
 
12
14
  group :development do
13
- gem "bundler", ">= 1.0.0"
14
- gem "jeweler", "~> 1.6.2"
15
- gem "rcov", ">= 0"
16
- gem "rdoc", ">= 2.4.0"
15
+ gem 'bundler', '>= 1.0.0'
16
+ gem 'jeweler', '~> 1.6.2'
17
+ gem 'rcov', '>= 0'
18
+ gem 'rdoc', '>= 2.4.0'
19
+ gem 'ruby-debug'
20
+ gem 'dm-sqlite-adapter'
17
21
  end
@@ -2,6 +2,7 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  addressable (2.2.6)
5
+ columnize (0.3.4)
5
6
  data_objects (0.10.6)
6
7
  addressable (~> 2.1)
7
8
  dm-core (1.1.0)
@@ -14,61 +15,69 @@ GEM
14
15
  dm-postgres-adapter (1.1.0)
15
16
  dm-do-adapter (~> 1.1.0)
16
17
  do_postgres (~> 0.10.2)
18
+ dm-sqlite-adapter (1.1.0)
19
+ dm-do-adapter (~> 1.1.0)
20
+ do_sqlite3 (~> 0.10.2)
17
21
  do_postgres (0.10.6)
18
22
  data_objects (= 0.10.6)
23
+ do_sqlite3 (0.10.6)
24
+ data_objects (= 0.10.6)
19
25
  faraday (0.6.1)
20
26
  addressable (~> 2.2.4)
21
27
  multipart-post (~> 1.1.0)
22
28
  rack (>= 1.1.0, < 2)
23
29
  git (1.2.5)
30
+ haml (3.1.2)
24
31
  jeweler (1.6.4)
25
32
  bundler (~> 1.0)
26
33
  git (>= 1.2.5)
27
34
  rake
35
+ linecache (0.46)
36
+ rbx-require-relative (> 0.0.4)
28
37
  mime-types (1.16)
29
38
  multi_json (0.0.5)
30
39
  multipart-post (1.1.3)
31
40
  net-ldap (0.1.1)
32
41
  nokogiri (1.4.7)
33
- oa-basic (0.2.3)
42
+ oa-basic (0.2.2)
34
43
  multi_json (~> 0.0.2)
35
44
  nokogiri (~> 1.4.2)
36
- oa-core (= 0.2.3)
45
+ oa-core (= 0.2.2)
37
46
  rest-client (~> 1.6.0)
38
- oa-core (0.2.3)
47
+ oa-core (0.2.2)
39
48
  rack (~> 1.1)
40
- oa-enterprise (0.2.3)
49
+ oa-enterprise (0.2.2)
41
50
  net-ldap (~> 0.1.1)
42
51
  nokogiri (~> 1.4.2)
43
- oa-core (= 0.2.3)
52
+ oa-core (= 0.2.2)
44
53
  pyu-ruby-sasl (~> 0.0.3.1)
45
54
  rubyntlm (~> 0.1.1)
46
- oa-more (0.2.3)
55
+ oa-more (0.2.2)
47
56
  multi_json (~> 0.0.2)
48
- oa-core (= 0.2.3)
57
+ oa-core (= 0.2.2)
49
58
  rest-client (~> 1.6.0)
50
- oa-oauth (0.2.3)
59
+ oa-oauth (0.2.2)
51
60
  faraday (~> 0.6.1)
52
- multi_json (>= 0.0.5)
61
+ multi_json (~> 0.0.2)
53
62
  nokogiri (~> 1.4.2)
54
- oa-core (= 0.2.3)
63
+ oa-core (= 0.2.2)
55
64
  oauth (~> 0.4.0)
56
65
  oauth2 (~> 0.3.0)
57
- oa-openid (0.2.3)
58
- oa-core (= 0.2.3)
66
+ oa-openid (0.2.2)
67
+ oa-core (= 0.2.2)
59
68
  rack-openid (~> 1.2.0)
60
69
  ruby-openid-apps-discovery
61
70
  oauth (0.4.5)
62
71
  oauth2 (0.3.0)
63
72
  faraday (~> 0.6.0)
64
73
  multi_json (~> 0.0.4)
65
- omniauth (0.2.3)
66
- oa-basic (= 0.2.3)
67
- oa-core (= 0.2.3)
68
- oa-enterprise (= 0.2.3)
69
- oa-more (= 0.2.3)
70
- oa-oauth (= 0.2.3)
71
- oa-openid (= 0.2.3)
74
+ omniauth (0.2.2)
75
+ oa-basic (= 0.2.2)
76
+ oa-core (= 0.2.2)
77
+ oa-enterprise (= 0.2.2)
78
+ oa-more (= 0.2.2)
79
+ oa-oauth (= 0.2.2)
80
+ oa-openid (= 0.2.2)
72
81
  pyu-ruby-sasl (0.0.3.3)
73
82
  rack (1.3.2)
74
83
  rack-flash (0.1.2)
@@ -77,10 +86,16 @@ GEM
77
86
  rack (>= 1.1.0)
78
87
  ruby-openid (>= 2.1.8)
79
88
  rake (0.9.2)
80
- rcov (0.9.9)
89
+ rbx-require-relative (0.0.5)
90
+ rcov (0.9.10)
81
91
  rdoc (3.9.1)
82
92
  rest-client (1.6.3)
83
93
  mime-types (>= 1.16)
94
+ ruby-debug (0.10.4)
95
+ columnize (>= 0.1)
96
+ ruby-debug-base (~> 0.10.4.0)
97
+ ruby-debug-base (0.10.4)
98
+ linecache (>= 0.3)
84
99
  ruby-openid (2.1.8)
85
100
  ruby-openid-apps-discovery (1.2.0)
86
101
  ruby-openid (>= 2.1.7)
@@ -90,6 +105,7 @@ GEM
90
105
  tilt (< 2.0, >= 1.2.2)
91
106
  sqlite3 (1.3.4)
92
107
  tilt (1.3.2)
108
+ uuidtools (2.1.2)
93
109
 
94
110
  PLATFORMS
95
111
  ruby
@@ -99,10 +115,14 @@ DEPENDENCIES
99
115
  dm-core
100
116
  dm-migrations
101
117
  dm-postgres-adapter
118
+ dm-sqlite-adapter
119
+ haml (>= 3.1.1)
102
120
  jeweler (~> 1.6.2)
103
- omniauth
121
+ omniauth (~> 0.2.2)
104
122
  rack-flash
105
123
  rcov
106
124
  rdoc (>= 2.4.0)
125
+ ruby-debug
107
126
  sinatra
108
127
  sqlite3
128
+ uuidtools
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 1.0.0
data/config.ru CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Driver program for Sinatra Omniauth gem.
3
+ # Driver program for SinatraOmniAuth gem.
4
4
  # You don't need to use this in your program, it just demonstrates the minimum to get things running
5
5
  #
6
6
 
@@ -8,18 +8,21 @@ require 'sinatra'
8
8
  require 'dm-core'
9
9
  require 'dm-migrations'
10
10
  require 'dm-sqlite-adapter'
11
+ require 'sinatra/omniauth'
12
+ require 'ruby-debug'; Debugger.start
11
13
 
12
14
  DataMapper::Logger.new($stdout, :debug)
13
15
  DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/omniauth_sinatra.sqlite3")
14
16
 
15
17
  DataMapper.auto_upgrade!
16
18
 
17
- app = Sinatra::Omniauth.new
19
+ class SinatraOmniAuthTestApp < Sinatra::Base
20
+ set :public, Dir.getwd
21
+ set :omniauth, YAML.load_file(File.dirname(__FILE__)+"/omniauth.yml")
22
+ enable :sessions
18
23
 
19
- # Set up API keys:
20
- app.settings.set :omniauth, {
21
- :facebook => []
22
- # etc...
23
- }
24
+ register SinatraOmniAuth
25
+ end
24
26
 
27
+ app = SinatraOmniAuthTestApp.new
25
28
  run app
@@ -1,4 +1,7 @@
1
1
  /* Authentication "badge" */
2
+ .authentications > * {
3
+ padding: 1em 1em;
4
+ }
2
5
  .authentication {
3
6
  position: relative;
4
7
  display: inline-block;
@@ -23,6 +23,7 @@
23
23
  #
24
24
  # require 'sinatra/omniauth'
25
25
  #
26
+ # enable :sessions
26
27
  # set :omniauth, YAML.load_file(File.dirname(__FILE__)+"/omniauth.yml")
27
28
  #
28
29
  # register SinatraOmniAuth
@@ -91,11 +92,26 @@ require 'rack-flash'
91
92
  module SinatraOmniAuth
92
93
  module Helpers
93
94
  def current_user
94
- @current_user ||= User.get(session[:user_id]) if session[:user_id]
95
+ session.delete :authentication_id # Clean up old auth values
96
+ begin
97
+ if session[:user_id] && session[:authentication_provider]
98
+ @current_auth ||= Authentication.first(:user_id => session[:user_id], :provider => session[:authentication_provider])
99
+ @current_user ||= @current_auth.user
100
+ end
101
+ return @current_user if @current_user
102
+ rescue # Invalid cookie value formats?
103
+ @current_user = nil
104
+ @current_auth = nil
105
+ end
106
+
107
+ # Clean up any old/bad cookie values:
108
+ session.delete :user_id
109
+ session.delete :authentication_provider
95
110
  end
96
111
 
97
112
  def current_auth
98
- @current_auth ||= Authentication.get(session[:authentication_id]) if session[:authentication_id]
113
+ current_user
114
+ @current_auth
99
115
  end
100
116
 
101
117
  def authenticate_user!
@@ -140,11 +156,11 @@ module SinatraOmniAuth
140
156
  @authentications_possible = settings.omniauth
141
157
 
142
158
  if current_user
143
- @authentication_current = Authentication.get(session[:authentication_id])
159
+ @authentication_current = current_auth
144
160
  @authentications_available = current_user.authentications.all(:order => [ :provider.desc ])
145
161
  @authentications_unused = @authentications_available.
146
162
  reject do|a|
147
- a.id == @authentication_current.id
163
+ a.provider == @authentication_current.provider
148
164
  end
149
165
  @authentications_possible = @authentications_possible.dup.
150
166
  reject do |a|
@@ -219,12 +235,12 @@ module SinatraOmniAuth
219
235
  if current_user
220
236
  if auth
221
237
  flash.notice = 'You are now signed in using your' + @authhash[:provider].capitalize + ' account'
222
- session[:authentication_id] = auth.id # They're now signed in using the new account
238
+ session[:authentication_provider] = auth.provider # They're now signed in using the new account
223
239
  redirect to('/auth/signedin') # Already signed in, and we already had this authentication
224
240
  else
225
241
  auth = current_user.authentications.create!(:provider => @authhash[:provider], :uid => @authhash[:uid], :user_name => @authhash[:name], :user_email => @authhash[:email])
226
242
  flash.notice = 'Your ' + @authhash[:provider].capitalize + ' account has been added for signing in at this site.'
227
- session[:authentication_id] = auth.id # They're now signed in using the new account
243
+ session[:authentication_provider] = auth.provider # They're now signed in using the new account
228
244
  session[:user_name] = @authhash[:name] if @authhash[:name] != ''
229
245
  redirect to('/auth/signedin')
230
246
  end
@@ -233,7 +249,7 @@ module SinatraOmniAuth
233
249
  # Signin existing user
234
250
  # in the session his user id and the authentication id used for signing in is stored
235
251
  session[:user_id] = auth.user.id
236
- session[:authentication_id] = auth.id
252
+ session[:authentication_provider] = auth.provider # They're now signed in using the new account
237
253
  session[:user_name] = @authhash[:name] if @authhash[:name] != ''
238
254
 
239
255
  flash.notice = 'Signed in successfully via ' + @authhash[:provider].capitalize + '.'
@@ -245,7 +261,7 @@ module SinatraOmniAuth
245
261
  session[:user_id] = @current_user.id
246
262
  session[:user_name] = @authhash[:name] if @authhash[:name] != ''
247
263
  auth = current_user.authentications.create!(:provider => @authhash[:provider], :uid => @authhash[:uid], :user_name => @authhash[:name], :user_email => @authhash[:email])
248
- session[:authentication_id] = auth.id
264
+ session[:authentication_provider] = auth.provider
249
265
  redirect to('/auth/welcome')
250
266
  end
251
267
  end
@@ -258,12 +274,9 @@ module SinatraOmniAuth
258
274
  app.get '/auth/signout' do
259
275
  authenticate_user!
260
276
 
261
- session[:user_id] = nil
262
- session[:user_name] = nil
263
- session[:authentication_id] = nil
264
277
  session.delete :user_id
265
278
  session.delete :user_name
266
- session.delete :authentication_id
279
+ session.delete :authentication_provider
267
280
  flash.notice = 'You have been signed out'
268
281
  redirect to('/')
269
282
  end
@@ -275,7 +288,7 @@ module SinatraOmniAuth
275
288
  # remove an authentication authentication linked to the current user
276
289
  @authentication = current_user.authentications.get(params[:id])
277
290
 
278
- if session[:authentication_id] == @authentication.id
291
+ if session[:authentication_provider] == @authentication.provider
279
292
  flash.error = 'You can\'t delete this authorization because you are currently signed in with it!'
280
293
  else
281
294
  @authentication.destroy
@@ -1,12 +1,15 @@
1
1
  class Authentication
2
2
  include DataMapper::Resource
3
3
 
4
- belongs_to :user
4
+ belongs_to :user, :key => true
5
5
 
6
- property :id, Serial
7
- property :user_id, Integer
8
- property :provider, String
6
+ # Authentication provider:
7
+ property :provider, String, :key => true
8
+
9
+ # User ID allocated by that provider:
9
10
  property :uid, String, :length => 240
11
+
12
+ # User name and email:
10
13
  property :user_name, String, :length => 240
11
- property :user_email, String, :length => 240
14
+ property :user_email, String, :length => 240, :index => true
12
15
  end
@@ -1,11 +1,9 @@
1
+ require 'uuidtools'
2
+
1
3
  class User
2
4
  include DataMapper::Resource
3
5
 
4
- devise :registerable, # handles signing up users through a registration process, also edit/destroy account.
5
- :rememberable, # "Remember me" from a cookie
6
- :trackable # Tracks sign in count, timestamps and IP address
7
-
8
- property :id, Serial
6
+ property :id, UUID, :key => true, :required => true, :default => proc { UUIDTools::UUID.random_create }
9
7
 
10
8
  # Each user may log in using different methods:
11
9
  has n, :authentications
@@ -61,13 +61,9 @@
61
61
  provider: openid
62
62
  name: Yahoo
63
63
  identifier: 'yahoo.com'
64
- key: --- enter your key here ---
65
- secret: --- enter your secret here ---
66
64
 
67
65
  -
68
66
  provider: openid
69
67
  name: AOL
70
68
  identifier: 'openid.aol.com'
71
- key: --- enter your key here ---
72
- secret: --- enter your secret here ---
73
69
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_omniauth}
8
- s.version = "0.2.2"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Clifford Heath}]
12
- s.date = %q{2011-08-08}
12
+ s.date = %q{2011-08-10}
13
13
  s.description = %q{This Sinatra extension, derived from omniauth_pure by Marcus Proske, adds OmniAuth authorization to your Sinatra application, so your users can login using FaceBook, Twitter and many other authorization providers, as long as you supply the API keys. It uses DataMapper and HAML.}
14
14
  s.email = %q{clifford.heath@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,61 +26,58 @@ Gem::Specification.new do |s|
26
26
  "VERSION",
27
27
  "config.ru",
28
28
  "css/auth.css",
29
- "lib/models/authorization.rb",
30
- "lib/models/user.rb",
29
+ "images/authbuttons/aol_128.png",
30
+ "images/authbuttons/aol_256.png",
31
+ "images/authbuttons/aol_32.png",
32
+ "images/authbuttons/aol_64.png",
33
+ "images/authbuttons/basecamp_128.png",
34
+ "images/authbuttons/basecamp_256.png",
35
+ "images/authbuttons/basecamp_32.png",
36
+ "images/authbuttons/basecamp_64.png",
37
+ "images/authbuttons/campfire_128.png",
38
+ "images/authbuttons/campfire_256.png",
39
+ "images/authbuttons/campfire_32.png",
40
+ "images/authbuttons/campfire_64.png",
41
+ "images/authbuttons/facebook_128.png",
42
+ "images/authbuttons/facebook_256.png",
43
+ "images/authbuttons/facebook_32.png",
44
+ "images/authbuttons/facebook_64.png",
45
+ "images/authbuttons/github_128.png",
46
+ "images/authbuttons/github_256.png",
47
+ "images/authbuttons/github_32.png",
48
+ "images/authbuttons/github_64.png",
49
+ "images/authbuttons/google_128.png",
50
+ "images/authbuttons/google_256.png",
51
+ "images/authbuttons/google_32.png",
52
+ "images/authbuttons/google_64.png",
53
+ "images/authbuttons/linkedin_128.png",
54
+ "images/authbuttons/linkedin_256.png",
55
+ "images/authbuttons/linkedin_32.png",
56
+ "images/authbuttons/linkedin_64.png",
57
+ "images/authbuttons/myspace_128.png",
58
+ "images/authbuttons/myspace_256.png",
59
+ "images/authbuttons/myspace_32.png",
60
+ "images/authbuttons/myspace_64.png",
61
+ "images/authbuttons/openid_128.png",
62
+ "images/authbuttons/openid_256.png",
63
+ "images/authbuttons/openid_32.png",
64
+ "images/authbuttons/openid_64.png",
65
+ "images/authbuttons/presently_128.png",
66
+ "images/authbuttons/presently_256.png",
67
+ "images/authbuttons/presently_32.png",
68
+ "images/authbuttons/presently_64.png",
69
+ "images/authbuttons/twitter_128.png",
70
+ "images/authbuttons/twitter_256.png",
71
+ "images/authbuttons/twitter_32.png",
72
+ "images/authbuttons/twitter_64.png",
73
+ "images/authbuttons/yahoo_128.png",
74
+ "images/authbuttons/yahoo_256.png",
75
+ "images/authbuttons/yahoo_32.png",
76
+ "images/authbuttons/yahoo_64.png",
31
77
  "lib/sinatra/omniauth.rb",
32
78
  "models/authentication.rb",
33
79
  "models/user.rb",
34
80
  "omniauth.yml",
35
- "public/css/omniauth.css",
36
- "public/images/authbuttons/aol_128.png",
37
- "public/images/authbuttons/aol_256.png",
38
- "public/images/authbuttons/aol_32.png",
39
- "public/images/authbuttons/aol_64.png",
40
- "public/images/authbuttons/basecamp_128.png",
41
- "public/images/authbuttons/basecamp_256.png",
42
- "public/images/authbuttons/basecamp_32.png",
43
- "public/images/authbuttons/basecamp_64.png",
44
- "public/images/authbuttons/campfire_128.png",
45
- "public/images/authbuttons/campfire_256.png",
46
- "public/images/authbuttons/campfire_32.png",
47
- "public/images/authbuttons/campfire_64.png",
48
- "public/images/authbuttons/facebook_128.png",
49
- "public/images/authbuttons/facebook_256.png",
50
- "public/images/authbuttons/facebook_32.png",
51
- "public/images/authbuttons/facebook_64.png",
52
- "public/images/authbuttons/github_128.png",
53
- "public/images/authbuttons/github_256.png",
54
- "public/images/authbuttons/github_32.png",
55
- "public/images/authbuttons/github_64.png",
56
- "public/images/authbuttons/google_128.png",
57
- "public/images/authbuttons/google_256.png",
58
- "public/images/authbuttons/google_32.png",
59
- "public/images/authbuttons/google_64.png",
60
- "public/images/authbuttons/linkedin_128.png",
61
- "public/images/authbuttons/linkedin_256.png",
62
- "public/images/authbuttons/linkedin_32.png",
63
- "public/images/authbuttons/linkedin_64.png",
64
- "public/images/authbuttons/myspace_128.png",
65
- "public/images/authbuttons/myspace_256.png",
66
- "public/images/authbuttons/myspace_32.png",
67
- "public/images/authbuttons/myspace_64.png",
68
- "public/images/authbuttons/openid_128.png",
69
- "public/images/authbuttons/openid_256.png",
70
- "public/images/authbuttons/openid_32.png",
71
- "public/images/authbuttons/openid_64.png",
72
- "public/images/authbuttons/presently_128.png",
73
- "public/images/authbuttons/presently_256.png",
74
- "public/images/authbuttons/presently_32.png",
75
- "public/images/authbuttons/presently_64.png",
76
- "public/images/authbuttons/twitter_128.png",
77
- "public/images/authbuttons/twitter_256.png",
78
- "public/images/authbuttons/twitter_32.png",
79
- "public/images/authbuttons/twitter_64.png",
80
- "public/images/authbuttons/yahoo_128.png",
81
- "public/images/authbuttons/yahoo_256.png",
82
- "public/images/authbuttons/yahoo_32.png",
83
- "public/images/authbuttons/yahoo_64.png",
84
81
  "sinatra_omniauth.gemspec",
85
82
  "test/helper.rb",
86
83
  "test/test_sinatra_omniauth.rb",
@@ -97,41 +94,53 @@ Gem::Specification.new do |s|
97
94
 
98
95
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
99
96
  s.add_runtime_dependency(%q<sinatra>, [">= 0"])
100
- s.add_runtime_dependency(%q<omniauth>, [">= 0"])
97
+ s.add_runtime_dependency(%q<omniauth>, ["~> 0.2.2"])
101
98
  s.add_runtime_dependency(%q<dm-core>, [">= 0"])
102
99
  s.add_runtime_dependency(%q<dm-migrations>, [">= 0"])
103
100
  s.add_runtime_dependency(%q<dm-postgres-adapter>, [">= 0"])
104
101
  s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
105
102
  s.add_runtime_dependency(%q<rack-flash>, [">= 0"])
103
+ s.add_runtime_dependency(%q<uuidtools>, [">= 0"])
104
+ s.add_runtime_dependency(%q<haml>, [">= 3.1.1"])
106
105
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
107
106
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
108
107
  s.add_development_dependency(%q<rcov>, [">= 0"])
109
108
  s.add_development_dependency(%q<rdoc>, [">= 2.4.0"])
109
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
110
+ s.add_development_dependency(%q<dm-sqlite-adapter>, [">= 0"])
110
111
  else
111
112
  s.add_dependency(%q<sinatra>, [">= 0"])
112
- s.add_dependency(%q<omniauth>, [">= 0"])
113
+ s.add_dependency(%q<omniauth>, ["~> 0.2.2"])
113
114
  s.add_dependency(%q<dm-core>, [">= 0"])
114
115
  s.add_dependency(%q<dm-migrations>, [">= 0"])
115
116
  s.add_dependency(%q<dm-postgres-adapter>, [">= 0"])
116
117
  s.add_dependency(%q<sqlite3>, [">= 0"])
117
118
  s.add_dependency(%q<rack-flash>, [">= 0"])
119
+ s.add_dependency(%q<uuidtools>, [">= 0"])
120
+ s.add_dependency(%q<haml>, [">= 3.1.1"])
118
121
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
119
122
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
120
123
  s.add_dependency(%q<rcov>, [">= 0"])
121
124
  s.add_dependency(%q<rdoc>, [">= 2.4.0"])
125
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
126
+ s.add_dependency(%q<dm-sqlite-adapter>, [">= 0"])
122
127
  end
123
128
  else
124
129
  s.add_dependency(%q<sinatra>, [">= 0"])
125
- s.add_dependency(%q<omniauth>, [">= 0"])
130
+ s.add_dependency(%q<omniauth>, ["~> 0.2.2"])
126
131
  s.add_dependency(%q<dm-core>, [">= 0"])
127
132
  s.add_dependency(%q<dm-migrations>, [">= 0"])
128
133
  s.add_dependency(%q<dm-postgres-adapter>, [">= 0"])
129
134
  s.add_dependency(%q<sqlite3>, [">= 0"])
130
135
  s.add_dependency(%q<rack-flash>, [">= 0"])
136
+ s.add_dependency(%q<uuidtools>, [">= 0"])
137
+ s.add_dependency(%q<haml>, [">= 3.1.1"])
131
138
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
132
139
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
133
140
  s.add_dependency(%q<rcov>, [">= 0"])
134
141
  s.add_dependency(%q<rdoc>, [">= 2.4.0"])
142
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
143
+ s.add_dependency(%q<dm-sqlite-adapter>, [">= 0"])
135
144
  end
136
145
  end
137
146
 
@@ -2,23 +2,29 @@
2
2
  %html(lang="en-au")
3
3
  %head
4
4
  %meta(charset="utf-8")
5
- = include_stylesheets :auth
6
- = include_javascripts :jquery
5
+ %link(rel="stylesheet" href="css/auth.css" media="screen" type="text/css")
6
+ %script(href="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript")
7
7
  %title APRIMO Sign In
8
8
 
9
9
  %body
10
+ - if flash.error || flash.notice
11
+ = flash.error || flash.notice
12
+
10
13
  .authentications
11
14
  - if current_user
12
15
  %section.current
13
- = current_auth.user_name+','
14
- you are currently signed in using your
16
+ You are currently signed in using as
17
+ = current_auth.user_name
18
+ using your
15
19
  .authentication.current{:style=>"background-image: url(/images/authbuttons/#{@authentication_current.provider}_32.png)"}
16
20
  .provider= @authentication_current.provider.titleize
17
21
  .uid= @authentication_current.uid
18
22
  account.
23
+
19
24
  %section.logout
20
25
  %a.signout{:href=>'/auth/signout'}Click here
21
26
  to sign out.
27
+
22
28
  %section.alternatives
23
29
  - if @authentications_available.size > 1
24
30
  .clear
@@ -28,6 +34,7 @@
28
34
  .provider= a.provider.titleize
29
35
  .uid= a.uid
30
36
  %a.remove{:href=>"/auth/#{a.id}", :method => :delete, :rel => 'nofollow', :'data-confirm' => 'Are you sure you want to remove this authentication option?'} x
37
+
31
38
  %section.join
32
39
  - if current_user
33
40
  - if @authentications_possible.size > 0
@@ -41,16 +48,17 @@
41
48
  - @authentications_possible.each do |authentication|
42
49
  .authentication{:style=>"background-image: url(/images/authbuttons/#{authentication['provider']}_32.png)",:onclick=>"location = '/auth/#{(a = authentication['provider']) == 'openid' ? authentication['name'].downcase : a}';"}
43
50
  .provider= authentication['name']
44
- - if !current_user
45
- %p.clear
46
- Don't have any of these accounts? Get your
47
- %a{href='http://www.myopenid.com/'} MyOpenID
48
- or
49
- %a{href='http://mail.google.com/mail/signup'} GoogleID
50
- now!
51
- If you want to learn more about OpenID or find more OpenID providers,
52
- you can get more information at
53
- %a{href='http://myopenid.net/'} openid.net
51
+
52
+ - if !current_user
53
+ %p.clear
54
+ Don't have any of these accounts? Get your
55
+ %a(href='http://www.myopenid.com/') MyOpenID
56
+ or
57
+ %a(href='http://mail.google.com/mail/signup') GoogleID
58
+ now!
59
+ If you want to learn more about OpenID or find more OpenID providers,
60
+ you can get more information at
61
+ %a(href='http://myopenid.net/') openid.net
54
62
 
55
63
  %script{:type=>'text/javascript'}
56
64
  $(document).ready(function() {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_omniauth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Clifford Heath
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-08 00:00:00 Z
18
+ date: 2011-08-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -35,12 +35,14 @@ dependencies:
35
35
  version_requirements: &id002 !ruby/object:Gem::Requirement
36
36
  none: false
37
37
  requirements:
38
- - - ">="
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- hash: 3
40
+ hash: 19
41
41
  segments:
42
42
  - 0
43
- version: "0"
43
+ - 2
44
+ - 2
45
+ version: 0.2.2
44
46
  prerelease: false
45
47
  type: :runtime
46
48
  requirement: *id002
@@ -117,6 +119,36 @@ dependencies:
117
119
  name: rack-flash
118
120
  - !ruby/object:Gem::Dependency
119
121
  version_requirements: &id008 !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ prerelease: false
131
+ type: :runtime
132
+ requirement: *id008
133
+ name: uuidtools
134
+ - !ruby/object:Gem::Dependency
135
+ version_requirements: &id009 !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 1
141
+ segments:
142
+ - 3
143
+ - 1
144
+ - 1
145
+ version: 3.1.1
146
+ prerelease: false
147
+ type: :runtime
148
+ requirement: *id009
149
+ name: haml
150
+ - !ruby/object:Gem::Dependency
151
+ version_requirements: &id010 !ruby/object:Gem::Requirement
120
152
  none: false
121
153
  requirements:
122
154
  - - ">="
@@ -129,10 +161,10 @@ dependencies:
129
161
  version: 1.0.0
130
162
  prerelease: false
131
163
  type: :development
132
- requirement: *id008
164
+ requirement: *id010
133
165
  name: bundler
134
166
  - !ruby/object:Gem::Dependency
135
- version_requirements: &id009 !ruby/object:Gem::Requirement
167
+ version_requirements: &id011 !ruby/object:Gem::Requirement
136
168
  none: false
137
169
  requirements:
138
170
  - - ~>
@@ -145,10 +177,10 @@ dependencies:
145
177
  version: 1.6.2
146
178
  prerelease: false
147
179
  type: :development
148
- requirement: *id009
180
+ requirement: *id011
149
181
  name: jeweler
150
182
  - !ruby/object:Gem::Dependency
151
- version_requirements: &id010 !ruby/object:Gem::Requirement
183
+ version_requirements: &id012 !ruby/object:Gem::Requirement
152
184
  none: false
153
185
  requirements:
154
186
  - - ">="
@@ -159,10 +191,10 @@ dependencies:
159
191
  version: "0"
160
192
  prerelease: false
161
193
  type: :development
162
- requirement: *id010
194
+ requirement: *id012
163
195
  name: rcov
164
196
  - !ruby/object:Gem::Dependency
165
- version_requirements: &id011 !ruby/object:Gem::Requirement
197
+ version_requirements: &id013 !ruby/object:Gem::Requirement
166
198
  none: false
167
199
  requirements:
168
200
  - - ">="
@@ -175,8 +207,36 @@ dependencies:
175
207
  version: 2.4.0
176
208
  prerelease: false
177
209
  type: :development
178
- requirement: *id011
210
+ requirement: *id013
179
211
  name: rdoc
212
+ - !ruby/object:Gem::Dependency
213
+ version_requirements: &id014 !ruby/object:Gem::Requirement
214
+ none: false
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ hash: 3
219
+ segments:
220
+ - 0
221
+ version: "0"
222
+ prerelease: false
223
+ type: :development
224
+ requirement: *id014
225
+ name: ruby-debug
226
+ - !ruby/object:Gem::Dependency
227
+ version_requirements: &id015 !ruby/object:Gem::Requirement
228
+ none: false
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ hash: 3
233
+ segments:
234
+ - 0
235
+ version: "0"
236
+ prerelease: false
237
+ type: :development
238
+ requirement: *id015
239
+ name: dm-sqlite-adapter
180
240
  description: This Sinatra extension, derived from omniauth_pure by Marcus Proske, adds OmniAuth authorization to your Sinatra application, so your users can login using FaceBook, Twitter and many other authorization providers, as long as you supply the API keys. It uses DataMapper and HAML.
181
241
  email: clifford.heath@gmail.com
182
242
  executables: []
@@ -196,61 +256,58 @@ files:
196
256
  - VERSION
197
257
  - config.ru
198
258
  - css/auth.css
199
- - lib/models/authorization.rb
200
- - lib/models/user.rb
259
+ - images/authbuttons/aol_128.png
260
+ - images/authbuttons/aol_256.png
261
+ - images/authbuttons/aol_32.png
262
+ - images/authbuttons/aol_64.png
263
+ - images/authbuttons/basecamp_128.png
264
+ - images/authbuttons/basecamp_256.png
265
+ - images/authbuttons/basecamp_32.png
266
+ - images/authbuttons/basecamp_64.png
267
+ - images/authbuttons/campfire_128.png
268
+ - images/authbuttons/campfire_256.png
269
+ - images/authbuttons/campfire_32.png
270
+ - images/authbuttons/campfire_64.png
271
+ - images/authbuttons/facebook_128.png
272
+ - images/authbuttons/facebook_256.png
273
+ - images/authbuttons/facebook_32.png
274
+ - images/authbuttons/facebook_64.png
275
+ - images/authbuttons/github_128.png
276
+ - images/authbuttons/github_256.png
277
+ - images/authbuttons/github_32.png
278
+ - images/authbuttons/github_64.png
279
+ - images/authbuttons/google_128.png
280
+ - images/authbuttons/google_256.png
281
+ - images/authbuttons/google_32.png
282
+ - images/authbuttons/google_64.png
283
+ - images/authbuttons/linkedin_128.png
284
+ - images/authbuttons/linkedin_256.png
285
+ - images/authbuttons/linkedin_32.png
286
+ - images/authbuttons/linkedin_64.png
287
+ - images/authbuttons/myspace_128.png
288
+ - images/authbuttons/myspace_256.png
289
+ - images/authbuttons/myspace_32.png
290
+ - images/authbuttons/myspace_64.png
291
+ - images/authbuttons/openid_128.png
292
+ - images/authbuttons/openid_256.png
293
+ - images/authbuttons/openid_32.png
294
+ - images/authbuttons/openid_64.png
295
+ - images/authbuttons/presently_128.png
296
+ - images/authbuttons/presently_256.png
297
+ - images/authbuttons/presently_32.png
298
+ - images/authbuttons/presently_64.png
299
+ - images/authbuttons/twitter_128.png
300
+ - images/authbuttons/twitter_256.png
301
+ - images/authbuttons/twitter_32.png
302
+ - images/authbuttons/twitter_64.png
303
+ - images/authbuttons/yahoo_128.png
304
+ - images/authbuttons/yahoo_256.png
305
+ - images/authbuttons/yahoo_32.png
306
+ - images/authbuttons/yahoo_64.png
201
307
  - lib/sinatra/omniauth.rb
202
308
  - models/authentication.rb
203
309
  - models/user.rb
204
310
  - omniauth.yml
205
- - public/css/omniauth.css
206
- - public/images/authbuttons/aol_128.png
207
- - public/images/authbuttons/aol_256.png
208
- - public/images/authbuttons/aol_32.png
209
- - public/images/authbuttons/aol_64.png
210
- - public/images/authbuttons/basecamp_128.png
211
- - public/images/authbuttons/basecamp_256.png
212
- - public/images/authbuttons/basecamp_32.png
213
- - public/images/authbuttons/basecamp_64.png
214
- - public/images/authbuttons/campfire_128.png
215
- - public/images/authbuttons/campfire_256.png
216
- - public/images/authbuttons/campfire_32.png
217
- - public/images/authbuttons/campfire_64.png
218
- - public/images/authbuttons/facebook_128.png
219
- - public/images/authbuttons/facebook_256.png
220
- - public/images/authbuttons/facebook_32.png
221
- - public/images/authbuttons/facebook_64.png
222
- - public/images/authbuttons/github_128.png
223
- - public/images/authbuttons/github_256.png
224
- - public/images/authbuttons/github_32.png
225
- - public/images/authbuttons/github_64.png
226
- - public/images/authbuttons/google_128.png
227
- - public/images/authbuttons/google_256.png
228
- - public/images/authbuttons/google_32.png
229
- - public/images/authbuttons/google_64.png
230
- - public/images/authbuttons/linkedin_128.png
231
- - public/images/authbuttons/linkedin_256.png
232
- - public/images/authbuttons/linkedin_32.png
233
- - public/images/authbuttons/linkedin_64.png
234
- - public/images/authbuttons/myspace_128.png
235
- - public/images/authbuttons/myspace_256.png
236
- - public/images/authbuttons/myspace_32.png
237
- - public/images/authbuttons/myspace_64.png
238
- - public/images/authbuttons/openid_128.png
239
- - public/images/authbuttons/openid_256.png
240
- - public/images/authbuttons/openid_32.png
241
- - public/images/authbuttons/openid_64.png
242
- - public/images/authbuttons/presently_128.png
243
- - public/images/authbuttons/presently_256.png
244
- - public/images/authbuttons/presently_32.png
245
- - public/images/authbuttons/presently_64.png
246
- - public/images/authbuttons/twitter_128.png
247
- - public/images/authbuttons/twitter_256.png
248
- - public/images/authbuttons/twitter_32.png
249
- - public/images/authbuttons/twitter_64.png
250
- - public/images/authbuttons/yahoo_128.png
251
- - public/images/authbuttons/yahoo_256.png
252
- - public/images/authbuttons/yahoo_32.png
253
- - public/images/authbuttons/yahoo_64.png
254
311
  - sinatra_omniauth.gemspec
255
312
  - test/helper.rb
256
313
  - test/test_sinatra_omniauth.rb
@@ -1,16 +0,0 @@
1
- require 'dm-core'
2
- require 'dm-timestamps'
3
-
4
- class Authorization
5
- include DataMapper::Resource
6
- belongs_to :user
7
-
8
- property :id, Serial
9
- property :user_id, Integer
10
- property :provider, String
11
- property :uid, String
12
- property :uname, String
13
- property :uemail, String
14
- property :created_at, DateTime
15
- property :updated_at, DateTime
16
- end
@@ -1,14 +0,0 @@
1
- require 'dm-core'
2
- require 'dm-timestamps'
3
-
4
- class User
5
- include DataMapper::Resource
6
-
7
- property :id, Serial
8
- property :name, String
9
- property :email, String
10
- property :created_at, DateTime
11
- property :updated_at, DateTime
12
-
13
- has n, :authorizations
14
- end
@@ -1,34 +0,0 @@
1
- /* Authentication "badge" */
2
- .authentication {
3
- position: relative;
4
- display: inline-block;
5
- padding: 0.2em 2em 0.2em 0.5em;
6
- background-color: #EEE;
7
- border-radius: 0.5em; border: 2px black;
8
- -webkit-box-shadow: 0 0 5px #000; -moz-box-shadow: 0 0 5px #000; box-shadow: 0 0 5px #000;
9
- }
10
- .authentication {
11
- background-repeat: no-repeat;
12
- background-position: left center;
13
- }
14
- .authentication * {
15
- margin-left: 32px;
16
- }
17
- .authentication .provider {
18
- font-weight: bold;
19
- }
20
- .authentication a { /* The X to delete this authentication method */
21
- position: absolute;
22
- right: 0.3em;
23
- top: 0px;
24
- }
25
-
26
- /* Alternate auth providers */
27
- .auth_provider {
28
- position: relative;
29
- display: inline-block;
30
- text-align: center;
31
- }
32
- .auth_provider * {
33
- display:block;
34
- }