vidibus-user 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -13,12 +13,12 @@ Warden::Strategies.add(:connector) do
13
13
  # To protect the service's secret, a custom signature will be sent instead.
14
14
  def credentials
15
15
  @credentials ||= begin
16
- connector = Service.connector
17
- raise "Failed to set Connector credentials! Service has not been set up, Connector data is missing." unless this and connector
16
+ service = Service(:user, realm)
17
+ raise "Failed to set service credentials! This service has not been set up, user service is missing." unless this and service
18
18
  {
19
- :client_id => this.uuid,
20
- :client_secret => Vidibus::Secure.sign("#{connector.url}#{this.uuid}", this.secret),
21
- :connector_url => connector.url
19
+ :client_id => "#{this.uuid}-#{realm}",
20
+ :client_secret => Vidibus::Secure.sign("#{service.url}#{this.uuid}", service.secret),
21
+ :service_url => service.url
22
22
  }
23
23
  end
24
24
  end
@@ -28,9 +28,14 @@ Warden::Strategies.add(:connector) do
28
28
  @this ||= Service.this
29
29
  end
30
30
 
31
+ # Returns the current realm
32
+ def realm
33
+ @realm ||= env[:realm] || raise("No realm available!")
34
+ end
35
+
31
36
  # Returns OAuth client
32
37
  def client
33
- @client ||= OAuth2::Client.new(credentials[:client_id], credentials[:client_secret], :site => credentials[:connector_url])
38
+ @client ||= OAuth2::Client.new(credentials[:client_id], credentials[:client_secret], :site => credentials[:service_url])
34
39
  end
35
40
 
36
41
  def authenticate!
@@ -38,14 +43,17 @@ Warden::Strategies.add(:connector) do
38
43
  redirect_url = "#{host}/authenticate_user"
39
44
 
40
45
  # Fetch code first
41
- return redirect!(client.web_server.authorize_url(:redirect_url => redirect_url)) unless code
46
+ args = { :redirect_url => redirect_url }
47
+ return redirect!(client.web_server.authorize_url(args)) unless code
42
48
 
43
49
  # Exchange code for token and fetch user data
44
50
  access_token = client.web_server.get_access_token(code, :redirect_url => redirect_url)
45
- user_data = JSON.parse(access_token.get("/me"))
51
+ user_data = JSON.parse(access_token.get("/oauth/user"))
46
52
 
47
53
  unless user = User.where(:email => user_data["email"]).first
48
- user = User.create!(user_data)
54
+ unless user = User.create(user_data)
55
+ raise "user.errors = #{user.errors.inspect}"
56
+ end
49
57
  end
50
58
  success!(user)
51
59
  rescue OAuth2::HTTPError => e
@@ -61,4 +69,4 @@ Warden::Strategies.add(:connector) do
61
69
  def protocol
62
70
  env["SERVER_PORT"] == 443 ? "https://" : "http://"
63
71
  end
64
- end
72
+ end
data/vidibus-user.gemspec CHANGED
@@ -1,45 +1,43 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vidibus-user}
8
- s.version = "0.0.0"
8
+ s.version = "0.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andre Pankratz"]
12
- s.date = %q{2010-10-02}
12
+ s.date = %q{2011-01-02}
13
13
  s.description = %q{Provides single sign-on and a local user model.}
14
14
  s.email = %q{andre@vidibus.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- ".rspec",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "LICENSE",
26
- "README.rdoc",
27
- "Rakefile",
28
- "VERSION",
29
- "app/models/user.rb",
30
- "config/routes.rb",
31
- "lib/vidibus-user.rb",
32
- "lib/vidibus/user.rb",
33
- "lib/vidibus/user/callback_app.rb",
34
- "lib/vidibus/user/extensions.rb",
35
- "lib/vidibus/user/extensions/controller.rb",
36
- "lib/vidibus/user/mongoid.rb",
37
- "lib/vidibus/user/warden_strategy.rb",
38
- "spec/spec_helper.rb",
39
- "vidibus-user.gemspec"
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "app/models/user.rb",
29
+ "config/routes.rb",
30
+ "lib/vidibus-user.rb",
31
+ "lib/vidibus/user.rb",
32
+ "lib/vidibus/user/callback_app.rb",
33
+ "lib/vidibus/user/extensions.rb",
34
+ "lib/vidibus/user/extensions/controller.rb",
35
+ "lib/vidibus/user/mongoid.rb",
36
+ "lib/vidibus/user/warden_strategy.rb",
37
+ "spec/spec_helper.rb",
38
+ "vidibus-user.gemspec"
40
39
  ]
41
40
  s.homepage = %q{http://github.com/vidibus/vidibus-user}
42
- s.rdoc_options = ["--charset=UTF-8"]
43
41
  s.require_paths = ["lib"]
44
42
  s.rubygems_version = %q{1.3.7}
45
43
  s.summary = %q{Single sign-on for Vidibus applications.}
@@ -52,6 +50,19 @@ Gem::Specification.new do |s|
52
50
  s.specification_version = 3
53
51
 
54
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_runtime_dependency(%q<rails>, ["~> 3.0.0"])
54
+ s.add_runtime_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
55
+ s.add_runtime_dependency(%q<warden>, [">= 0"])
56
+ s.add_runtime_dependency(%q<oauth2>, [">= 0"])
57
+ s.add_runtime_dependency(%q<json>, [">= 0"])
58
+ s.add_runtime_dependency(%q<vidibus-uuid>, [">= 0"])
59
+ s.add_runtime_dependency(%q<vidibus-secure>, [">= 0"])
60
+ s.add_runtime_dependency(%q<jeweler>, [">= 0"])
61
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
62
+ s.add_runtime_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
63
+ s.add_runtime_dependency(%q<rr>, [">= 0"])
64
+ s.add_runtime_dependency(%q<relevance-rcov>, [">= 0"])
65
+ s.add_runtime_dependency(%q<webmock>, [">= 0"])
55
66
  s.add_runtime_dependency(%q<rails>, ["~> 3.0.0"])
56
67
  s.add_runtime_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
57
68
  s.add_runtime_dependency(%q<warden>, [">= 0"])
@@ -59,6 +70,19 @@ Gem::Specification.new do |s|
59
70
  s.add_runtime_dependency(%q<vidibus-secure>, [">= 0"])
60
71
  s.add_runtime_dependency(%q<vidibus-uuid>, [">= 0"])
61
72
  else
73
+ s.add_dependency(%q<rails>, ["~> 3.0.0"])
74
+ s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
75
+ s.add_dependency(%q<warden>, [">= 0"])
76
+ s.add_dependency(%q<oauth2>, [">= 0"])
77
+ s.add_dependency(%q<json>, [">= 0"])
78
+ s.add_dependency(%q<vidibus-uuid>, [">= 0"])
79
+ s.add_dependency(%q<vidibus-secure>, [">= 0"])
80
+ s.add_dependency(%q<jeweler>, [">= 0"])
81
+ s.add_dependency(%q<rake>, [">= 0"])
82
+ s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
83
+ s.add_dependency(%q<rr>, [">= 0"])
84
+ s.add_dependency(%q<relevance-rcov>, [">= 0"])
85
+ s.add_dependency(%q<webmock>, [">= 0"])
62
86
  s.add_dependency(%q<rails>, ["~> 3.0.0"])
63
87
  s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
64
88
  s.add_dependency(%q<warden>, [">= 0"])
@@ -67,6 +91,19 @@ Gem::Specification.new do |s|
67
91
  s.add_dependency(%q<vidibus-uuid>, [">= 0"])
68
92
  end
69
93
  else
94
+ s.add_dependency(%q<rails>, ["~> 3.0.0"])
95
+ s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
96
+ s.add_dependency(%q<warden>, [">= 0"])
97
+ s.add_dependency(%q<oauth2>, [">= 0"])
98
+ s.add_dependency(%q<json>, [">= 0"])
99
+ s.add_dependency(%q<vidibus-uuid>, [">= 0"])
100
+ s.add_dependency(%q<vidibus-secure>, [">= 0"])
101
+ s.add_dependency(%q<jeweler>, [">= 0"])
102
+ s.add_dependency(%q<rake>, [">= 0"])
103
+ s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
104
+ s.add_dependency(%q<rr>, [">= 0"])
105
+ s.add_dependency(%q<relevance-rcov>, [">= 0"])
106
+ s.add_dependency(%q<webmock>, [">= 0"])
70
107
  s.add_dependency(%q<rails>, ["~> 3.0.0"])
71
108
  s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
72
109
  s.add_dependency(%q<warden>, [">= 0"])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidibus-user
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 1
10
+ version: 0.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andre Pankratz
@@ -15,13 +15,14 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-02 00:00:00 +02:00
18
+ date: 2011-01-02 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rails
22
+ type: :runtime
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ name: rails
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
28
  - - ~>
@@ -32,12 +33,12 @@ dependencies:
32
33
  - 0
33
34
  - 0
34
35
  version: 3.0.0
35
- type: :runtime
36
- version_requirements: *id001
36
+ requirement: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: mongoid
38
+ type: :runtime
39
39
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ name: mongoid
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
43
44
  - - ~>
@@ -50,12 +51,12 @@ dependencies:
50
51
  - beta
51
52
  - 20
52
53
  version: 2.0.0.beta.20
53
- type: :runtime
54
- version_requirements: *id002
54
+ requirement: *id002
55
55
  - !ruby/object:Gem::Dependency
56
- name: warden
56
+ type: :runtime
57
57
  prerelease: false
58
- requirement: &id003 !ruby/object:Gem::Requirement
58
+ name: warden
59
+ version_requirements: &id003 !ruby/object:Gem::Requirement
59
60
  none: false
60
61
  requirements:
61
62
  - - ">="
@@ -64,12 +65,26 @@ dependencies:
64
65
  segments:
65
66
  - 0
66
67
  version: "0"
67
- type: :runtime
68
- version_requirements: *id003
68
+ requirement: *id003
69
69
  - !ruby/object:Gem::Dependency
70
+ type: :runtime
71
+ prerelease: false
70
72
  name: oauth2
73
+ version_requirements: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ requirement: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ type: :runtime
71
85
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
86
+ name: json
87
+ version_requirements: &id005 !ruby/object:Gem::Requirement
73
88
  none: false
74
89
  requirements:
75
90
  - - ">="
@@ -78,12 +93,40 @@ dependencies:
78
93
  segments:
79
94
  - 0
80
95
  version: "0"
96
+ requirement: *id005
97
+ - !ruby/object:Gem::Dependency
81
98
  type: :runtime
82
- version_requirements: *id004
99
+ prerelease: false
100
+ name: vidibus-uuid
101
+ version_requirements: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirement: *id006
83
111
  - !ruby/object:Gem::Dependency
112
+ type: :runtime
113
+ prerelease: false
84
114
  name: vidibus-secure
115
+ version_requirements: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ requirement: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ type: :runtime
85
127
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
128
+ name: jeweler
129
+ version_requirements: &id008 !ruby/object:Gem::Requirement
87
130
  none: false
88
131
  requirements:
89
132
  - - ">="
@@ -92,12 +135,58 @@ dependencies:
92
135
  segments:
93
136
  - 0
94
137
  version: "0"
138
+ requirement: *id008
139
+ - !ruby/object:Gem::Dependency
95
140
  type: :runtime
96
- version_requirements: *id005
141
+ prerelease: false
142
+ name: rake
143
+ version_requirements: &id009 !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ hash: 3
149
+ segments:
150
+ - 0
151
+ version: "0"
152
+ requirement: *id009
97
153
  - !ruby/object:Gem::Dependency
98
- name: vidibus-uuid
154
+ type: :runtime
155
+ prerelease: false
156
+ name: rspec
157
+ version_requirements: &id010 !ruby/object:Gem::Requirement
158
+ none: false
159
+ requirements:
160
+ - - ~>
161
+ - !ruby/object:Gem::Version
162
+ hash: 62196427
163
+ segments:
164
+ - 2
165
+ - 0
166
+ - 0
167
+ - beta
168
+ - 20
169
+ version: 2.0.0.beta.20
170
+ requirement: *id010
171
+ - !ruby/object:Gem::Dependency
172
+ type: :runtime
173
+ prerelease: false
174
+ name: rr
175
+ version_requirements: &id011 !ruby/object:Gem::Requirement
176
+ none: false
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ hash: 3
181
+ segments:
182
+ - 0
183
+ version: "0"
184
+ requirement: *id011
185
+ - !ruby/object:Gem::Dependency
186
+ type: :runtime
99
187
  prerelease: false
100
- requirement: &id006 !ruby/object:Gem::Requirement
188
+ name: relevance-rcov
189
+ version_requirements: &id012 !ruby/object:Gem::Requirement
101
190
  none: false
102
191
  requirements:
103
192
  - - ">="
@@ -106,8 +195,111 @@ dependencies:
106
195
  segments:
107
196
  - 0
108
197
  version: "0"
198
+ requirement: *id012
199
+ - !ruby/object:Gem::Dependency
109
200
  type: :runtime
110
- version_requirements: *id006
201
+ prerelease: false
202
+ name: webmock
203
+ version_requirements: &id013 !ruby/object:Gem::Requirement
204
+ none: false
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ hash: 3
209
+ segments:
210
+ - 0
211
+ version: "0"
212
+ requirement: *id013
213
+ - !ruby/object:Gem::Dependency
214
+ type: :runtime
215
+ prerelease: false
216
+ name: rails
217
+ version_requirements: &id014 !ruby/object:Gem::Requirement
218
+ none: false
219
+ requirements:
220
+ - - ~>
221
+ - !ruby/object:Gem::Version
222
+ hash: 7
223
+ segments:
224
+ - 3
225
+ - 0
226
+ - 0
227
+ version: 3.0.0
228
+ requirement: *id014
229
+ - !ruby/object:Gem::Dependency
230
+ type: :runtime
231
+ prerelease: false
232
+ name: mongoid
233
+ version_requirements: &id015 !ruby/object:Gem::Requirement
234
+ none: false
235
+ requirements:
236
+ - - ~>
237
+ - !ruby/object:Gem::Version
238
+ hash: 62196427
239
+ segments:
240
+ - 2
241
+ - 0
242
+ - 0
243
+ - beta
244
+ - 20
245
+ version: 2.0.0.beta.20
246
+ requirement: *id015
247
+ - !ruby/object:Gem::Dependency
248
+ type: :runtime
249
+ prerelease: false
250
+ name: warden
251
+ version_requirements: &id016 !ruby/object:Gem::Requirement
252
+ none: false
253
+ requirements:
254
+ - - ">="
255
+ - !ruby/object:Gem::Version
256
+ hash: 3
257
+ segments:
258
+ - 0
259
+ version: "0"
260
+ requirement: *id016
261
+ - !ruby/object:Gem::Dependency
262
+ type: :runtime
263
+ prerelease: false
264
+ name: oauth2
265
+ version_requirements: &id017 !ruby/object:Gem::Requirement
266
+ none: false
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ hash: 3
271
+ segments:
272
+ - 0
273
+ version: "0"
274
+ requirement: *id017
275
+ - !ruby/object:Gem::Dependency
276
+ type: :runtime
277
+ prerelease: false
278
+ name: vidibus-secure
279
+ version_requirements: &id018 !ruby/object:Gem::Requirement
280
+ none: false
281
+ requirements:
282
+ - - ">="
283
+ - !ruby/object:Gem::Version
284
+ hash: 3
285
+ segments:
286
+ - 0
287
+ version: "0"
288
+ requirement: *id018
289
+ - !ruby/object:Gem::Dependency
290
+ type: :runtime
291
+ prerelease: false
292
+ name: vidibus-uuid
293
+ version_requirements: &id019 !ruby/object:Gem::Requirement
294
+ none: false
295
+ requirements:
296
+ - - ">="
297
+ - !ruby/object:Gem::Version
298
+ hash: 3
299
+ segments:
300
+ - 0
301
+ version: "0"
302
+ requirement: *id019
111
303
  description: Provides single sign-on and a local user model.
112
304
  email: andre@vidibus.com
113
305
  executables: []
@@ -119,7 +311,6 @@ extra_rdoc_files:
119
311
  - README.rdoc
120
312
  files:
121
313
  - .document
122
- - .gitignore
123
314
  - .rspec
124
315
  - Gemfile
125
316
  - Gemfile.lock
@@ -143,8 +334,8 @@ homepage: http://github.com/vidibus/vidibus-user
143
334
  licenses: []
144
335
 
145
336
  post_install_message:
146
- rdoc_options:
147
- - --charset=UTF-8
337
+ rdoc_options: []
338
+
148
339
  require_paths:
149
340
  - lib
150
341
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- .bundle