omni_auth_passaporte_web 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +48 -0
- data/Rakefile +7 -0
- data/lib/omni_auth_passaporte_web/passaporte_web.rb +54 -0
- data/lib/omni_auth_passaporte_web.rb +7 -0
- data/omni_auth_passaporte_web.gemspec +19 -0
- data/spec/omni_auth_myfc_id/myfc_id_spec.rb +41 -0
- data/spec/spec.opts +7 -0
- data/spec/spec_helper.rb +1 -0
- metadata +94 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omni_auth_passaporte_web (0.0.1.pre)
|
5
|
+
oa-oauth (= 0.2.6)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.2.6)
|
11
|
+
diff-lcs (1.1.2)
|
12
|
+
faraday (0.6.1)
|
13
|
+
addressable (~> 2.2.4)
|
14
|
+
multipart-post (~> 1.1.0)
|
15
|
+
rack (>= 1.1.0, < 2)
|
16
|
+
multi_json (1.0.3)
|
17
|
+
multi_xml (0.2.2)
|
18
|
+
multipart-post (1.1.3)
|
19
|
+
oa-core (0.2.6)
|
20
|
+
oa-oauth (0.2.6)
|
21
|
+
faraday (~> 0.6.1)
|
22
|
+
multi_json (~> 1.0.0)
|
23
|
+
multi_xml (~> 0.2.2)
|
24
|
+
oa-core (= 0.2.6)
|
25
|
+
oauth (~> 0.4.0)
|
26
|
+
oauth2 (~> 0.4.1)
|
27
|
+
oauth (0.4.5)
|
28
|
+
oauth2 (0.4.1)
|
29
|
+
faraday (~> 0.6.1)
|
30
|
+
multi_json (>= 0.0.5)
|
31
|
+
rack (1.3.5)
|
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)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
omni_auth_passaporte_web!
|
47
|
+
rake (= 0.8.4)
|
48
|
+
rspec (= 2.6.0)
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
#
|
7
|
+
# Authenticate to Myfcid via OAuth and retrieve an access token for API usage
|
8
|
+
#
|
9
|
+
# Usage:
|
10
|
+
#
|
11
|
+
# use OmniAuth::Strategies::Myfcid, 'consumerkey', 'consumersecret', {:site=> 'http://stage.id.myfreecomm.com.br'}
|
12
|
+
#
|
13
|
+
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, :myfcid, 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
|
+
|
25
|
+
def auth_hash
|
26
|
+
OmniAuth::Utils.deep_merge(super, {
|
27
|
+
'uid' => user_data['uuid'],
|
28
|
+
'user_info' => user_info,
|
29
|
+
'extra' => {
|
30
|
+
'user_hash' => user_data
|
31
|
+
}
|
32
|
+
})
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def user_data
|
38
|
+
@result ||= @access_token.post('/sso/fetchuserdata', nil)
|
39
|
+
@data ||= MultiJson.decode(@result.body)
|
40
|
+
end
|
41
|
+
|
42
|
+
def user_info
|
43
|
+
{
|
44
|
+
'nickname' => user_data['nickname'],
|
45
|
+
'email' => user_data['email'],
|
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
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = %q{omni_auth_passaporte_web}
|
6
|
+
s.version = "0.0.1.pre"
|
7
|
+
s.authors = ["Marcos Tapajos"]
|
8
|
+
s.email = ["marcos@tapajos.me"]
|
9
|
+
s.homepage = %q{http://myfreecomm.com.br}
|
10
|
+
s.summary = %q{Autenticação via SSO usando o Passaporte Web}
|
11
|
+
s.description = s.summary
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.add_dependency('oa-oauth', '0.2.6')
|
17
|
+
s.add_development_dependency('rspec', '2.6.0')
|
18
|
+
s.add_development_dependency('rake', '0.8.4')
|
19
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/omni_auth_myfc_id'
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omni_auth_passaporte_web
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marcos Tapajos
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-24 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: oa-oauth
|
16
|
+
requirement: &70136159887600 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.2.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70136159887600
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70136159886340 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.6.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70136159886340
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70136159885300 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.8.4
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70136159885300
|
47
|
+
description: Autenticação via SSO usando o Passaporte Web
|
48
|
+
email:
|
49
|
+
- marcos@tapajos.me
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
57
|
+
- Rakefile
|
58
|
+
- lib/omni_auth_passaporte_web.rb
|
59
|
+
- lib/omni_auth_passaporte_web/passaporte_web.rb
|
60
|
+
- omni_auth_passaporte_web.gemspec
|
61
|
+
- spec/omni_auth_myfc_id/myfc_id_spec.rb
|
62
|
+
- spec/spec.opts
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
homepage: http://myfreecomm.com.br
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
hash: 3519927953676899148
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>'
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.3.1
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.10
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Autenticação via SSO usando o Passaporte Web
|
91
|
+
test_files:
|
92
|
+
- spec/omni_auth_myfc_id/myfc_id_spec.rb
|
93
|
+
- spec/spec.opts
|
94
|
+
- spec/spec_helper.rb
|