oa-globocom 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -10
- data/lib/oa-globocom/version.rb +1 -1
- data/lib/omni_auth/strategies/globocom.rb +7 -11
- data/oa-globocom.gemspec +1 -1
- data/spec/omni_auth/strategies/globocom_spec.rb +2 -2
- metadata +17 -17
data/README.md
CHANGED
@@ -7,9 +7,9 @@ The goal of this gem is to create a bridge between Globo.com's authentication an
|
|
7
7
|
Add into your Gemfile
|
8
8
|
|
9
9
|
gem "oa-globocom"
|
10
|
-
|
10
|
+
|
11
11
|
## Configuration
|
12
|
-
|
12
|
+
|
13
13
|
The middleware has 2 important options: `:service_id` and `:config_file`.
|
14
14
|
:service_id is the number of your service at Globo.com.
|
15
15
|
:config_file is the YAML formatted file with the urls you want to use:
|
@@ -17,13 +17,12 @@ The middleware has 2 important options: `:service_id` and `:config_file`.
|
|
17
17
|
cadun:
|
18
18
|
logout_url: https://login.dev.globoi.com/Servlet/do/logout
|
19
19
|
login_url: https://login.dev.globoi.com/login
|
20
|
-
auth_url: isp-authenticator.dev.globoi.com
|
21
|
-
auth_port: 8280
|
20
|
+
auth_url: isp-authenticator.dev.globoi.com:8280
|
22
21
|
|
23
22
|
The `config_file` must be in that format, otherwise it won't work. The final result will look like this:
|
24
23
|
|
25
24
|
config.middleware.use OmniAuth::Strategies::GloboCom, :service_id => 1234, :config_file => "#{File.dirname(__FILE__)}/cadun.yml"
|
26
|
-
|
25
|
+
|
27
26
|
After that, you just need to follow the OmniAuth standard configuration creating a callback controller to handle the CadUn's redirect. Something like this:
|
28
27
|
|
29
28
|
class SessionsController < ActionController::Base
|
@@ -38,7 +37,7 @@ After that, you just need to follow the OmniAuth standard configuration creating
|
|
38
37
|
rescue ActiveRecord::RecordNotFound
|
39
38
|
User.create_from_omniauth(auth)
|
40
39
|
end
|
41
|
-
|
40
|
+
|
42
41
|
session[:user_id] = user.id
|
43
42
|
redirect_to root_url
|
44
43
|
else
|
@@ -52,7 +51,7 @@ After that, you just need to follow the OmniAuth standard configuration creating
|
|
52
51
|
redirect_to root_url
|
53
52
|
end
|
54
53
|
end
|
55
|
-
|
54
|
+
|
56
55
|
That way the controller will check if OmniAuth has returned the Globo.com's data, if so it will find or create an user, if not it will redirect the user back to the CadUn authentication screen.
|
57
56
|
|
58
57
|
And set your routes:
|
@@ -60,7 +59,7 @@ And set your routes:
|
|
60
59
|
match "/auth/cadun" => "sessions#new"
|
61
60
|
match "/auth/cadun/callback" => "sessions#create"
|
62
61
|
match "/auth/cadun/logout" => "sessions#destroy"
|
63
|
-
|
62
|
+
|
64
63
|
|
65
64
|
## Tips: Dynamic Service Ids
|
66
65
|
|
@@ -69,7 +68,7 @@ Let's say your application works with many service ids. You can work with a "SET
|
|
69
68
|
Add to the configuration:
|
70
69
|
|
71
70
|
config.middleware.use OmniAuth::Strategies::GloboCom, :service_id => 1234, :setup => true, :config => "cadun.yml"
|
72
|
-
|
71
|
+
|
73
72
|
Then add to your callback controller:
|
74
73
|
|
75
74
|
class SessionsController < ActionController::Base
|
@@ -78,7 +77,7 @@ Then add to your callback controller:
|
|
78
77
|
render :nothing => true, :status => 404
|
79
78
|
end
|
80
79
|
end
|
81
|
-
|
80
|
+
|
82
81
|
It's really important to finish the action with a 404 status. It says to OmniAuth that it can go ahead and complete the flow.
|
83
82
|
|
84
83
|
The setup step can change the options of the Strategy, so you can change the service id and the redirect will go to any service you set up.
|
data/lib/oa-globocom/version.rb
CHANGED
@@ -8,10 +8,10 @@ module OmniAuth
|
|
8
8
|
class GloboCom
|
9
9
|
include OmniAuth::Strategy
|
10
10
|
|
11
|
-
def initialize(app,
|
12
|
-
Cadun::Config.load_file(
|
11
|
+
def initialize(app, opts = {})
|
12
|
+
Cadun::Config.load_file(opts[:config])
|
13
13
|
|
14
|
-
super(app, :cadun,
|
14
|
+
super(app, :cadun, opts)
|
15
15
|
end
|
16
16
|
|
17
17
|
def request_phase
|
@@ -27,7 +27,10 @@ module OmniAuth
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def auth_hash
|
30
|
-
|
30
|
+
hash = { :provider => "cadun", :uid => user.id, :user_info => user.to_hash.merge(:birthday => user.birthday.strftime('%d/%m/%Y')) }
|
31
|
+
hash[:user_info].merge!(:GLBID => request.params['GLBID'], :url => request.params['url']) if request
|
32
|
+
|
33
|
+
hash
|
31
34
|
end
|
32
35
|
|
33
36
|
def user
|
@@ -54,13 +57,6 @@ module OmniAuth
|
|
54
57
|
env['REMOTE_ADDR']
|
55
58
|
end
|
56
59
|
end
|
57
|
-
|
58
|
-
def self.build_auth_hash(user, request = nil)
|
59
|
-
hash = { :provider => "cadun", :uid => user.id, :user_info => user.to_hash.merge(:birthday => user.birthday.strftime('%d/%m/%Y')) }
|
60
|
-
hash[:user_info].merge!(:GLBID => request.params['GLBID'], :url => request.params['url']) if request
|
61
|
-
|
62
|
-
hash
|
63
|
-
end
|
64
60
|
end
|
65
61
|
end
|
66
62
|
end
|
data/oa-globocom.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_paths = %w(lib)
|
17
17
|
|
18
18
|
s.add_dependency 'oa-core', '~> 0.2.6'
|
19
|
-
s.add_dependency 'cadun', '~> 0.5.
|
19
|
+
s.add_dependency 'cadun', '~> 0.5.5'
|
20
20
|
s.add_development_dependency 'rack'
|
21
21
|
s.add_development_dependency 'rake'
|
22
22
|
s.add_development_dependency 'rspec'
|
@@ -48,8 +48,8 @@ describe OmniAuth::Strategies::GloboCom do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it { strategy.env['omniauth.auth'].should be_nil }
|
51
|
-
it { strategy.env['omniauth.error'].should == "
|
52
|
-
it { strategy.env['omniauth.error.type'].should == :
|
51
|
+
it { strategy.env['omniauth.error'].should == "Unauthorized" }
|
52
|
+
it { strategy.env['omniauth.error.type'].should == :Unauthorized }
|
53
53
|
end
|
54
54
|
|
55
55
|
context "when the authorization succeeds" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oa-globocom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-07-
|
14
|
+
date: 2011-07-28 00:00:00.000000000Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: oa-core
|
18
|
-
requirement: &
|
18
|
+
requirement: &2156660480 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -23,21 +23,21 @@ dependencies:
|
|
23
23
|
version: 0.2.6
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *2156660480
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cadun
|
29
|
-
requirement: &
|
29
|
+
requirement: &2156659980 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.5.
|
34
|
+
version: 0.5.5
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *2156659980
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rack
|
40
|
-
requirement: &
|
40
|
+
requirement: &2156689280 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *2156689280
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: rake
|
51
|
-
requirement: &
|
51
|
+
requirement: &2156688820 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *2156688820
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rspec
|
62
|
-
requirement: &
|
62
|
+
requirement: &2156688400 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,10 +67,10 @@ dependencies:
|
|
67
67
|
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *2156688400
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rr
|
73
|
-
requirement: &
|
73
|
+
requirement: &2156687980 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - ! '>='
|
@@ -78,10 +78,10 @@ dependencies:
|
|
78
78
|
version: '0'
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
|
-
version_requirements: *
|
81
|
+
version_requirements: *2156687980
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: fakeweb
|
84
|
-
requirement: &
|
84
|
+
requirement: &2156687560 !ruby/object:Gem::Requirement
|
85
85
|
none: false
|
86
86
|
requirements:
|
87
87
|
- - ! '>='
|
@@ -89,7 +89,7 @@ dependencies:
|
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
|
-
version_requirements: *
|
92
|
+
version_requirements: *2156687560
|
93
93
|
description: The goal of this gem is to allow the developer to use ContaGlobo.com
|
94
94
|
(a login webservice made by Globo.com) in any web app using OmniAuth
|
95
95
|
email:
|