omni_auth_passaporte_web 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +26 -36
- data/README +1 -0
- data/lib/omni_auth_passaporte_web.rb +4 -4
- data/lib/omni_auth_passaporte_web/passaporte_web.rb +42 -38
- data/omni_auth_passaporte_web.gemspec +8 -7
- data/spec/omni_auth_passaporte_web/passaporte_web_spec.rb +4 -11
- metadata +52 -18
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,48 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
omni_auth_passaporte_web (
|
5
|
-
|
4
|
+
omni_auth_passaporte_web (3.0.0)
|
5
|
+
multi_json (>= 1.0.4)
|
6
|
+
omniauth-oauth (~> 1.0.1)
|
6
7
|
|
7
8
|
GEM
|
8
|
-
remote:
|
9
|
+
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
multi_json (~> 1.0)
|
31
|
-
rack (1.4.1)
|
32
|
-
rake (0.8.4)
|
33
|
-
rspec (2.6.0)
|
34
|
-
rspec-core (~> 2.6.0)
|
35
|
-
rspec-expectations (~> 2.6.0)
|
36
|
-
rspec-mocks (~> 2.6.0)
|
37
|
-
rspec-core (2.6.4)
|
38
|
-
rspec-expectations (2.6.0)
|
39
|
-
diff-lcs (~> 1.1.2)
|
40
|
-
rspec-mocks (2.6.0)
|
11
|
+
diff-lcs (1.2.1)
|
12
|
+
hashie (1.2.0)
|
13
|
+
multi_json (1.6.1)
|
14
|
+
oauth (0.4.7)
|
15
|
+
omniauth (1.1.3)
|
16
|
+
hashie (~> 1.2)
|
17
|
+
rack
|
18
|
+
omniauth-oauth (1.0.1)
|
19
|
+
oauth
|
20
|
+
omniauth (~> 1.0)
|
21
|
+
rack (1.5.2)
|
22
|
+
rake (10.0.3)
|
23
|
+
rspec (2.13.0)
|
24
|
+
rspec-core (~> 2.13.0)
|
25
|
+
rspec-expectations (~> 2.13.0)
|
26
|
+
rspec-mocks (~> 2.13.0)
|
27
|
+
rspec-core (2.13.0)
|
28
|
+
rspec-expectations (2.13.0)
|
29
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
30
|
+
rspec-mocks (2.13.0)
|
41
31
|
|
42
32
|
PLATFORMS
|
43
33
|
ruby
|
44
34
|
|
45
35
|
DEPENDENCIES
|
46
36
|
omni_auth_passaporte_web!
|
47
|
-
rake (
|
48
|
-
rspec (
|
37
|
+
rake (~> 10.0.3)
|
38
|
+
rspec (~> 2.13.0)
|
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
For usage example with Rails, see: https://github.com/myfreecomm/exemplo_passaporte_web_rails_3_2
|
@@ -1,7 +1,7 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
$:.unshift(File.dirname(__FILE__))
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
require 'omniauth/oauth'
|
4
|
+
require 'multi_json'
|
5
|
+
require 'omniauth-oauth'
|
6
6
|
require 'oauth/signature/plaintext'
|
7
|
-
require 'omni_auth_passaporte_web/passaporte_web'
|
7
|
+
require 'omni_auth_passaporte_web/passaporte_web'
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'multi_json'
|
3
|
-
|
1
|
+
# encoding: utf-8
|
4
2
|
module OmniAuth
|
5
3
|
module Strategies
|
6
4
|
#
|
@@ -8,47 +6,53 @@ module OmniAuth
|
|
8
6
|
#
|
9
7
|
# Usage:
|
10
8
|
#
|
11
|
-
# use OmniAuth::Strategies::PassaporteWeb, 'consumerkey', 'consumersecret', {:site=> 'http://sandbox.app.passaporteweb.com.br'}
|
9
|
+
# use OmniAuth::Strategies::PassaporteWeb, 'consumerkey', 'consumersecret', :client_options => {:site => 'http://sandbox.app.passaporteweb.com.br'}
|
12
10
|
#
|
13
11
|
class PassaporteWeb < OmniAuth::Strategies::OAuth
|
14
|
-
def initialize(app, consumer_key, consumer_secret, options = {})
|
15
|
-
@site = options.delete(:site) || 'https://sandbox.app.passaporteweb.com.br'
|
16
|
-
super(app, :passaporte_web, consumer_key, consumer_secret,
|
17
|
-
options.merge({:site => @site ,
|
18
|
-
:request_token_path => "/sso/initiate",
|
19
|
-
:authorize_path => "/sso/authorize",
|
20
|
-
:access_token_path => "/sso/token",
|
21
|
-
:signature_method => "PLAINTEXT"
|
22
|
-
}))
|
23
|
-
end
|
24
12
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
13
|
+
# Give your strategy a name.
|
14
|
+
option :name, "passaporte_web"
|
15
|
+
|
16
|
+
# This is where you pass the options you would pass when
|
17
|
+
# initializing your consumer from the OAuth gem.
|
18
|
+
option :client_options, {
|
19
|
+
:site => "http://sandbox.app.passaporteweb.com.br",
|
20
|
+
:request_token_path => "/sso/initiate",
|
21
|
+
:authorize_path => "/sso/authorize",
|
22
|
+
:access_token_path => "/sso/token",
|
23
|
+
:signature_method => "PLAINTEXT"
|
24
|
+
}
|
34
25
|
|
35
|
-
|
26
|
+
# These are called after authentication has succeeded. If
|
27
|
+
# possible, you should try to set the UID without making
|
28
|
+
# additional calls (if the user id is returned with the token
|
29
|
+
# or as a URI parameter). This may not be possible with all
|
30
|
+
# providers.
|
31
|
+
# uid{ request.params['uuid'] }
|
32
|
+
uid{ user_data['uuid'] }
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
info do
|
35
|
+
{
|
36
|
+
'uuid' => user_data['uuid'],
|
37
|
+
'nickname' => user_data['nickname'],
|
38
|
+
'email' => user_data['email'],
|
39
|
+
'first_name' => user_data['first_name'],
|
40
|
+
'last_name' => user_data['last_name'],
|
41
|
+
'name' => [user_data['first_name'], user_data['last_name']].join(' ').strip,
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
extra do
|
46
|
+
{
|
47
|
+
'user_hash' => user_data
|
48
|
+
}
|
49
|
+
end
|
41
50
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
'first_name' => user_data['first_name'],
|
47
|
-
'last_name' => user_data['last_name'],
|
48
|
-
'name' => [user_data['first_name'], user_data['last_name']].join(' ').strip,
|
49
|
-
}
|
50
|
-
end
|
51
|
+
def user_data
|
52
|
+
@result ||= access_token.post('/sso/fetchuserdata', nil)
|
53
|
+
@user_data ||= MultiJson.decode(@result.body)
|
54
|
+
end
|
51
55
|
|
52
56
|
end
|
53
57
|
end
|
54
|
-
end
|
58
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
2
|
$:.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 = "
|
7
|
-
s.authors = ["Marcos Tapajos"]
|
8
|
-
s.email = ["marcos@tapajos.me"]
|
6
|
+
s.version = "3.0.0"
|
7
|
+
s.authors = ["Rodrigo Tassinari de Oliveira", "Marcos Tapajos"]
|
8
|
+
s.email = ["rodrigo@pittlandia.net", "marcos@tapajos.me"]
|
9
9
|
s.homepage = %q{http://myfreecomm.com.br}
|
10
10
|
s.summary = %q{Autenticação via SSO usando o Passaporte Web}
|
11
11
|
s.description = s.summary
|
@@ -13,7 +13,8 @@ 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('
|
17
|
-
s.
|
18
|
-
s.add_development_dependency('
|
16
|
+
s.add_dependency('omniauth-oauth', '~> 1.0.1')
|
17
|
+
s.add_dependency('multi_json', '>= 1.0.4')
|
18
|
+
s.add_development_dependency('rspec', '~> 2.13.0')
|
19
|
+
s.add_development_dependency('rake', '~> 10.0.3')
|
19
20
|
end
|
@@ -18,23 +18,16 @@ describe OmniAuth::Strategies::PassaporteWeb do
|
|
18
18
|
:oauth_version=>"1.0",
|
19
19
|
:access_token_path=>"/sso/token",
|
20
20
|
:scheme=>:header,
|
21
|
-
:site=>"
|
21
|
+
:site=>"http://sandbox.app.passaporteweb.com.br"
|
22
22
|
}
|
23
23
|
end
|
24
24
|
|
25
25
|
describe ".auth_hash" do
|
26
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")
|
27
|
+
@access_token_mock.should_receive(:token).twice.and_return("token")
|
28
|
+
@access_token_mock.should_receive(:secret).twice.and_return("secret")
|
29
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
|
-
}
|
30
|
+
@passaporte_web.auth_hash.to_hash.should == {"provider"=>"passaporte_web", "uid"=>nil, "info"=>{"uuid"=>nil, "nickname"=>"nick", "email"=>"mail", "first_name"=>"Marcos", "last_name"=>"Tapajos", "name"=>"Marcos Tapajos"}, "credentials"=>{"token"=>"token", "secret"=>"secret"}, "extra"=>{"access_token"=>@access_token_mock, "user_hash"=>{"nickname"=>"nick", "last_name"=>"Tapajos", "email"=>"mail", "first_name"=>"Marcos"}}}
|
38
31
|
end
|
39
32
|
end
|
40
33
|
|
metadata
CHANGED
@@ -1,51 +1,84 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omni_auth_passaporte_web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
+
- Rodrigo Tassinari de Oliveira
|
8
9
|
- Marcos Tapajos
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
16
|
+
name: omniauth-oauth
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
|
-
- -
|
20
|
+
- - ~>
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
22
|
+
version: 1.0.1
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.0.1
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: multi_json
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.0.4
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.0.4
|
25
47
|
- !ruby/object:Gem::Dependency
|
26
48
|
name: rspec
|
27
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
28
50
|
none: false
|
29
51
|
requirements:
|
30
|
-
- -
|
52
|
+
- - ~>
|
31
53
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.
|
54
|
+
version: 2.13.0
|
33
55
|
type: :development
|
34
56
|
prerelease: false
|
35
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.13.0
|
36
63
|
- !ruby/object:Gem::Dependency
|
37
64
|
name: rake
|
38
|
-
requirement:
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
39
66
|
none: false
|
40
67
|
requirements:
|
41
|
-
- -
|
68
|
+
- - ~>
|
42
69
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
70
|
+
version: 10.0.3
|
44
71
|
type: :development
|
45
72
|
prerelease: false
|
46
|
-
version_requirements:
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 10.0.3
|
47
79
|
description: Autenticação via SSO usando o Passaporte Web
|
48
80
|
email:
|
81
|
+
- rodrigo@pittlandia.net
|
49
82
|
- marcos@tapajos.me
|
50
83
|
executables: []
|
51
84
|
extensions: []
|
@@ -54,6 +87,7 @@ files:
|
|
54
87
|
- .gitignore
|
55
88
|
- Gemfile
|
56
89
|
- Gemfile.lock
|
90
|
+
- README
|
57
91
|
- Rakefile
|
58
92
|
- lib/omni_auth_passaporte_web.rb
|
59
93
|
- lib/omni_auth_passaporte_web/passaporte_web.rb
|
@@ -75,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
109
|
version: '0'
|
76
110
|
segments:
|
77
111
|
- 0
|
78
|
-
hash:
|
112
|
+
hash: -242045153821639831
|
79
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
114
|
none: false
|
81
115
|
requirements:
|
@@ -84,10 +118,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
118
|
version: '0'
|
85
119
|
segments:
|
86
120
|
- 0
|
87
|
-
hash:
|
121
|
+
hash: -242045153821639831
|
88
122
|
requirements: []
|
89
123
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.8.
|
124
|
+
rubygems_version: 1.8.25
|
91
125
|
signing_key:
|
92
126
|
specification_version: 3
|
93
127
|
summary: Autenticação via SSO usando o Passaporte Web
|