vidibus-user 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -0
- data/VERSION +1 -1
- data/lib/vidibus/user/warden_strategy.rb +14 -6
- data/vidibus-user.gemspec +2 -2
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -6,6 +6,7 @@ This gem is part of the open source SOA framework Vidibus: vidibus.org.
|
|
6
6
|
|
7
7
|
It is far from being complete, but this will change soon.
|
8
8
|
|
9
|
+
|
9
10
|
== Installation
|
10
11
|
|
11
12
|
Add the dependency to the Gemfile of your application:
|
@@ -15,6 +16,17 @@ Add the dependency to the Gemfile of your application:
|
|
15
16
|
Then call bundle install on your console.
|
16
17
|
|
17
18
|
|
19
|
+
== Obtaining user data
|
20
|
+
|
21
|
+
After authorization via OAuth this gem requests user data from providing service. It will call the following route:
|
22
|
+
|
23
|
+
/oauth/user
|
24
|
+
|
25
|
+
It expects JSON data to be returned. The dataset must at least include the user's uuid.
|
26
|
+
|
27
|
+
The vidibus-oauth2_server gem will provide a controller for this task.
|
28
|
+
|
29
|
+
|
18
30
|
== Dependencies
|
19
31
|
|
20
32
|
In order to perform authentication, this gem depends on services provided by the vidibus-service gem.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -41,20 +41,28 @@ Warden::Strategies.add(:connector) do
|
|
41
41
|
def authenticate!
|
42
42
|
code = params["code"]
|
43
43
|
redirect_url = "#{host}/authenticate_user"
|
44
|
+
args = { :redirect_url => redirect_url }
|
44
45
|
|
45
46
|
# Fetch code first
|
46
|
-
args = { :redirect_url => redirect_url }
|
47
47
|
return redirect!(client.web_server.authorize_url(args)) unless code
|
48
48
|
|
49
|
-
# Exchange code for token
|
49
|
+
# Exchange code for token
|
50
50
|
access_token = client.web_server.get_access_token(code, :redirect_url => redirect_url)
|
51
|
-
user_data = JSON.parse(access_token.get("/oauth/user"))
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
# Try to fetch user data
|
53
|
+
begin
|
54
|
+
response = access_token.get("/oauth/user")
|
55
|
+
user_data = JSON.parse(response)
|
56
|
+
unless user = User.where(:uuid => user_data["uuid"]).first
|
57
|
+
unless user = User.create(user_data)
|
58
|
+
raise "user.errors = #{user.errors.inspect}"
|
59
|
+
end
|
56
60
|
end
|
61
|
+
rescue OAuth2::HTTPError
|
62
|
+
Rails.logger.error "Failed to fetch user data from #{credentials[:service_url]}/oauth/user"
|
63
|
+
user = true
|
57
64
|
end
|
65
|
+
|
58
66
|
success!(user)
|
59
67
|
rescue OAuth2::HTTPError => e
|
60
68
|
raise e.response.body
|
data/vidibus-user.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{vidibus-user}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
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{2011-01-
|
12
|
+
s.date = %q{2011-01-14}
|
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 = [
|
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andre Pankratz
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-14 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|