omni_auth_myfc_id 1.0.15.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ pkg
2
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in kumade.gemspec
4
+ gemspec
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omni_auth_myfc_id (1.0.15.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 (< 2, >= 1.1.0)
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.2)
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_myfc_id!
47
+ rake (= 0.8.4)
48
+ rspec (= 2.6.0)
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+ require 'bundler'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+
3
+ gem 'oa-oauth', '0.2.6'
4
+
5
+ require 'omniauth/oauth'
6
+ require 'oauth/signature/plaintext'
7
+ require 'omni_auth_myfc_id/myfcid'
@@ -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 Myfcid < OmniAuth::Strategies::OAuth
14
+ def initialize(app, consumer_key, consumer_secret, options = {})
15
+ @site = options.delete(:site) || 'https://id.myfreecomm.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_myfc_id}
6
+ s.version = "1.0.15.pre"
7
+ s.authors = ["Marcos Tapajos"]
8
+ s.email = ["marcos@tapajos.me"]
9
+ s.homepage = %q{http://myfreecomm.com.br}
10
+ s.summary = %q{summary}
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
@@ -0,0 +1,7 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
7
+ -rubygems
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/../lib/omni_auth_myfc_id'
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omni_auth_myfc_id
3
+ version: !ruby/object:Gem::Version
4
+ hash: 961916008
5
+ prerelease: 7
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 15
10
+ - pre
11
+ version: 1.0.15.pre
12
+ platform: ruby
13
+ authors:
14
+ - Marcos Tapajos
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-08-26 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ hash: 27
28
+ segments:
29
+ - 0
30
+ - 2
31
+ - 6
32
+ version: 0.2.6
33
+ name: oa-oauth
34
+ type: :runtime
35
+ prerelease: false
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ hash: 23
44
+ segments:
45
+ - 2
46
+ - 6
47
+ - 0
48
+ version: 2.6.0
49
+ name: rspec
50
+ type: :development
51
+ prerelease: false
52
+ requirement: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - "="
58
+ - !ruby/object:Gem::Version
59
+ hash: 55
60
+ segments:
61
+ - 0
62
+ - 8
63
+ - 4
64
+ version: 0.8.4
65
+ name: rake
66
+ type: :development
67
+ prerelease: false
68
+ requirement: *id003
69
+ description: summary
70
+ email:
71
+ - marcos@tapajos.me
72
+ executables: []
73
+
74
+ extensions: []
75
+
76
+ extra_rdoc_files: []
77
+
78
+ files:
79
+ - .gitignore
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - Rakefile
83
+ - lib/omni_auth_myfc_id.rb
84
+ - lib/omni_auth_myfc_id/myfcid.rb
85
+ - omni_auth_myfc_id.gemspec
86
+ - spec/omni_auth_myfc_id/myfc_id_spec.rb
87
+ - spec/spec.opts
88
+ - spec/spec_helper.rb
89
+ homepage: http://myfreecomm.com.br
90
+ licenses: []
91
+
92
+ post_install_message:
93
+ rdoc_options: []
94
+
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">"
110
+ - !ruby/object:Gem::Version
111
+ hash: 25
112
+ segments:
113
+ - 1
114
+ - 3
115
+ - 1
116
+ version: 1.3.1
117
+ requirements: []
118
+
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.6
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: summary
124
+ test_files:
125
+ - spec/omni_auth_myfc_id/myfc_id_spec.rb
126
+ - spec/spec.opts
127
+ - spec/spec_helper.rb