omni_auth_passaporte_web 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +20 -20
- data/lib/omni_auth_passaporte_web/passaporte_web.rb +6 -6
- data/lib/omni_auth_passaporte_web.rb +1 -1
- data/omni_auth_passaporte_web.gemspec +2 -2
- data/spec/omni_auth_passaporte_web/passaporte_web_spec.rb +41 -0
- data/spec/spec_helper.rb +1 -1
- metadata +49 -76
- data/spec/omni_auth_myfc_id/myfc_id_spec.rb +0 -41
data/Gemfile.lock
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
omni_auth_passaporte_web (
|
5
|
-
oa-oauth (= 0.2
|
4
|
+
omni_auth_passaporte_web (2.0.0)
|
5
|
+
oa-oauth (= 0.3.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.2.
|
10
|
+
addressable (2.2.7)
|
11
11
|
diff-lcs (1.1.2)
|
12
|
-
faraday (0.6
|
13
|
-
addressable (~> 2.2
|
14
|
-
multipart-post (~> 1.1
|
15
|
-
rack (
|
16
|
-
multi_json (1.0.
|
17
|
-
multi_xml (0.
|
18
|
-
multipart-post (1.1.
|
19
|
-
oa-core (0.2
|
20
|
-
oa-oauth (0.2
|
21
|
-
faraday (~> 0.
|
12
|
+
faraday (0.7.6)
|
13
|
+
addressable (~> 2.2)
|
14
|
+
multipart-post (~> 1.1)
|
15
|
+
rack (~> 1.1)
|
16
|
+
multi_json (1.0.4)
|
17
|
+
multi_xml (0.4.2)
|
18
|
+
multipart-post (1.1.5)
|
19
|
+
oa-core (0.3.2)
|
20
|
+
oa-oauth (0.3.2)
|
21
|
+
faraday (~> 0.7.3)
|
22
22
|
multi_json (~> 1.0.0)
|
23
|
-
multi_xml (~> 0.
|
24
|
-
oa-core (= 0.2
|
23
|
+
multi_xml (~> 0.4.0)
|
24
|
+
oa-core (= 0.3.2)
|
25
25
|
oauth (~> 0.4.0)
|
26
|
-
oauth2 (~> 0.
|
26
|
+
oauth2 (~> 0.5.0)
|
27
27
|
oauth (0.4.5)
|
28
|
-
oauth2 (0.
|
29
|
-
faraday (~> 0.
|
30
|
-
multi_json (
|
31
|
-
rack (1.
|
28
|
+
oauth2 (0.5.2)
|
29
|
+
faraday (~> 0.7)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
rack (1.4.1)
|
32
32
|
rake (0.8.4)
|
33
33
|
rspec (2.6.0)
|
34
34
|
rspec-core (~> 2.6.0)
|
@@ -4,13 +4,13 @@ require 'multi_json'
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
6
|
#
|
7
|
-
# Authenticate to
|
7
|
+
# Authenticate to PassaporteWeb via OAuth and retrieve an access token for API usage
|
8
8
|
#
|
9
9
|
# Usage:
|
10
10
|
#
|
11
|
-
# use OmniAuth::Strategies::
|
11
|
+
# use OmniAuth::Strategies::PassaporteWeb, 'consumerkey', 'consumersecret', {:site=> 'http://sandbox.app.passaporteweb.com.br'}
|
12
12
|
#
|
13
|
-
class PassaporteWeb < OmniAuth::Strategies::OAuth
|
13
|
+
class PassaporteWeb < OmniAuth::Strategies::OAuth
|
14
14
|
def initialize(app, consumer_key, consumer_secret, options = {})
|
15
15
|
@site = options.delete(:site) || 'https://sandbox.app.passaporteweb.com.br'
|
16
16
|
super(app, :passaporte_web, consumer_key, consumer_secret,
|
@@ -21,7 +21,7 @@ module OmniAuth
|
|
21
21
|
:signature_method => "PLAINTEXT"
|
22
22
|
}))
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def auth_hash
|
26
26
|
OmniAuth::Utils.deep_merge(super, {
|
27
27
|
'uid' => user_data['uuid'],
|
@@ -31,14 +31,14 @@ module OmniAuth
|
|
31
31
|
}
|
32
32
|
})
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
protected
|
36
36
|
|
37
37
|
def user_data
|
38
38
|
@result ||= @access_token.post('/sso/fetchuserdata', nil)
|
39
39
|
@data ||= MultiJson.decode(@result.body)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def user_info
|
43
43
|
{
|
44
44
|
'nickname' => user_data['nickname'],
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = %q{omni_auth_passaporte_web}
|
6
|
-
s.version = "
|
6
|
+
s.version = "2.0.0"
|
7
7
|
s.authors = ["Marcos Tapajos"]
|
8
8
|
s.email = ["marcos@tapajos.me"]
|
9
9
|
s.homepage = %q{http://myfreecomm.com.br}
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
14
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
15
|
s.require_paths = ["lib"]
|
16
|
-
s.add_dependency('oa-oauth', '0.2
|
16
|
+
s.add_dependency('oa-oauth', '0.3.2')
|
17
17
|
s.add_development_dependency('rspec', '2.6.0')
|
18
18
|
s.add_development_dependency('rake', '0.8.4')
|
19
19
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::PassaporteWeb do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@access_token_mock = mock("AccessToken")
|
7
|
+
@passaporte_web = OmniAuth::Strategies::PassaporteWeb.new("my_sample_app", "my_consumer_key", "my_consumer_secret")
|
8
|
+
@passaporte_web.instance_variable_set(:@access_token, @access_token_mock)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should set consumer options" do
|
12
|
+
@passaporte_web.consumer.options.should == {
|
13
|
+
:request_token_path=>"/sso/initiate",
|
14
|
+
:proxy=>nil,
|
15
|
+
:http_method=>:post,
|
16
|
+
:signature_method=>"PLAINTEXT",
|
17
|
+
:authorize_path=>"/sso/authorize",
|
18
|
+
:oauth_version=>"1.0",
|
19
|
+
:access_token_path=>"/sso/token",
|
20
|
+
:scheme=>:header,
|
21
|
+
:site=>"https://sandbox.app.passaporteweb.com.br"
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".auth_hash" do
|
26
|
+
it "should return auth_hash using server" do
|
27
|
+
@access_token_mock.should_receive(:token).and_return("token")
|
28
|
+
@access_token_mock.should_receive(:secret).and_return("secret")
|
29
|
+
@access_token_mock.should_receive(:post).with("/sso/fetchuserdata", nil).once.and_return(mock(:body => "{\"nickname\":\"nick\",\"last_name\":\"Tapajos\",\"email\":\"mail\",\"first_name\":\"Marcos\"}"))
|
30
|
+
@passaporte_web.auth_hash.should == {
|
31
|
+
"user_info"=>{"name"=>"Marcos Tapajos", "nickname"=>"nick", "last_name"=>"Tapajos", "first_name"=>"Marcos", "email"=>"mail"},
|
32
|
+
"uid"=>nil,
|
33
|
+
"credentials"=>{"token"=>"token", "secret"=>"secret"},
|
34
|
+
"extra"=>{"user_hash"=>{"nickname"=>"nick", "last_name"=>"Tapajos", "first_name"=>"Marcos", "email"=>"mail"},
|
35
|
+
"access_token"=>@access_token_mock},
|
36
|
+
"provider"=>"passaporte_web"
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../lib/
|
1
|
+
require File.dirname(__FILE__) + '/../lib/omni_auth_passaporte_web'
|
metadata
CHANGED
@@ -1,80 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: omni_auth_passaporte_web
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Marcos Tapajos
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
prerelease: false
|
12
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: oa-oauth
|
23
|
-
|
16
|
+
requirement: &70299455344160 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 2
|
32
|
-
- 6
|
33
|
-
version: 0.2.6
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.3.2
|
34
22
|
type: :runtime
|
35
|
-
requirement: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
23
|
prerelease: false
|
24
|
+
version_requirements: *70299455344160
|
25
|
+
- !ruby/object:Gem::Dependency
|
38
26
|
name: rspec
|
39
|
-
|
27
|
+
requirement: &70299455343460 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 23
|
45
|
-
segments:
|
46
|
-
- 2
|
47
|
-
- 6
|
48
|
-
- 0
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
49
32
|
version: 2.6.0
|
50
33
|
type: :development
|
51
|
-
requirement: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
34
|
prerelease: false
|
35
|
+
version_requirements: *70299455343460
|
36
|
+
- !ruby/object:Gem::Dependency
|
54
37
|
name: rake
|
55
|
-
|
38
|
+
requirement: &70299455342580 !ruby/object:Gem::Requirement
|
56
39
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
hash: 55
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
- 8
|
64
|
-
- 4
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
65
43
|
version: 0.8.4
|
66
44
|
type: :development
|
67
|
-
|
68
|
-
|
69
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70299455342580
|
47
|
+
description: Autenticação via SSO usando o Passaporte Web
|
48
|
+
email:
|
70
49
|
- marcos@tapajos.me
|
71
50
|
executables: []
|
72
|
-
|
73
51
|
extensions: []
|
74
|
-
|
75
52
|
extra_rdoc_files: []
|
76
|
-
|
77
|
-
files:
|
53
|
+
files:
|
78
54
|
- .gitignore
|
79
55
|
- Gemfile
|
80
56
|
- Gemfile.lock
|
@@ -82,43 +58,40 @@ files:
|
|
82
58
|
- lib/omni_auth_passaporte_web.rb
|
83
59
|
- lib/omni_auth_passaporte_web/passaporte_web.rb
|
84
60
|
- omni_auth_passaporte_web.gemspec
|
85
|
-
- spec/
|
61
|
+
- spec/omni_auth_passaporte_web/passaporte_web_spec.rb
|
86
62
|
- spec/spec.opts
|
87
63
|
- spec/spec_helper.rb
|
88
64
|
homepage: http://myfreecomm.com.br
|
89
65
|
licenses: []
|
90
|
-
|
91
66
|
post_install_message:
|
92
67
|
rdoc_options: []
|
93
|
-
|
94
|
-
require_paths:
|
68
|
+
require_paths:
|
95
69
|
- lib
|
96
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
71
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
segments:
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
segments:
|
103
77
|
- 0
|
104
|
-
|
105
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
hash: 2469858658958075657
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
80
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
segments:
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
segments:
|
112
86
|
- 0
|
113
|
-
|
87
|
+
hash: 2469858658958075657
|
114
88
|
requirements: []
|
115
|
-
|
116
89
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.8.
|
90
|
+
rubygems_version: 1.8.17
|
118
91
|
signing_key:
|
119
92
|
specification_version: 3
|
120
|
-
summary:
|
121
|
-
test_files:
|
122
|
-
- spec/
|
93
|
+
summary: Autenticação via SSO usando o Passaporte Web
|
94
|
+
test_files:
|
95
|
+
- spec/omni_auth_passaporte_web/passaporte_web_spec.rb
|
123
96
|
- spec/spec.opts
|
124
97
|
- spec/spec_helper.rb
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe OmniAuth::Strategies::Myfcid do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@access_token_mock = mock("AccessToken")
|
7
|
-
@myfc_id = OmniAuth::Strategies::Myfcid.new("my_sample_app", "my_consumer_key", "my_consumer_secret")
|
8
|
-
@myfc_id.instance_variable_set(:@access_token, @access_token_mock)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should set consumer options" do
|
12
|
-
@myfc_id.instance_variable_get(:@consumer).options.should == {:request_token_path=>"/sso/initiate",
|
13
|
-
:proxy=>nil,
|
14
|
-
:http_method=>:post,
|
15
|
-
:signature_method=>"PLAINTEXT",
|
16
|
-
:authorize_path=>"/sso/authorize",
|
17
|
-
:oauth_version=>"1.0",
|
18
|
-
:access_token_path=>"/sso/token",
|
19
|
-
:scheme=>:header,
|
20
|
-
:site=>"https://id.myfreecomm.com.br"}
|
21
|
-
end
|
22
|
-
|
23
|
-
describe ".auth_hash" do
|
24
|
-
|
25
|
-
it "should return auth_hash using server" do
|
26
|
-
@access_token_mock.should_receive(:token).and_return("token")
|
27
|
-
@access_token_mock.should_receive(:secret).and_return("secret")
|
28
|
-
@access_token_mock.should_receive(:post).with("/sso/fetchuserdata", nil).once.and_return(mock(:body => "{\"nickname\":\"nick\",\"last_name\":\"Tapajos\",\"email\":\"mail\",\"first_name\":\"Marcos\"}"))
|
29
|
-
@myfc_id.auth_hash.should == {
|
30
|
-
"user_info"=>{"name"=>"Marcos Tapajos", "nickname"=>"nick", "last_name"=>"Tapajos", "first_name"=>"Marcos", "email"=>"mail"},
|
31
|
-
"uid"=>nil,
|
32
|
-
"credentials"=>{"token"=>"token", "secret"=>"secret"},
|
33
|
-
"extra"=>{"user_hash"=>{"nickname"=>"nick", "last_name"=>"Tapajos", "first_name"=>"Marcos", "email"=>"mail"},
|
34
|
-
"access_token"=>@access_token_mock},
|
35
|
-
"provider"=>"myfcid"
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|