oa-more 0.2.0.beta2 → 0.2.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -13,4 +13,10 @@ To install just the providers in the "more" gem:
13
13
 
14
14
  gem install oa-more
15
15
 
16
+ == OmniAuth Builder
16
17
 
18
+ If you want to allow multiple providers, use the OmniAuth Builder:
19
+
20
+ use OmniAuth::Builder do
21
+ provider :flickr, 'api_key', 'secret_key', :scope => 'read'
22
+ end
data/lib/omniauth/more.rb CHANGED
@@ -2,6 +2,7 @@ require 'omniauth/core'
2
2
 
3
3
  module OmniAuth
4
4
  module Strategies
5
- # autoload strategies here
5
+ autoload :WindowsLive, 'omniauth/strategies/windows_live'
6
+ autoload :Flickr, 'omniauth/strategies/flickr'
6
7
  end
7
8
  end
@@ -0,0 +1,77 @@
1
+ require 'omniauth/core'
2
+ require 'digest/md5'
3
+ require 'rest-client'
4
+ require 'multi_json'
5
+
6
+ module OmniAuth
7
+ module Strategies
8
+ #
9
+ # Authenticate to Flickr
10
+ #
11
+ # @example Basic Usage
12
+ #
13
+ # use OmniAuth::Strategies::Flickr, 'API Key', 'Secret Key', :scope => 'read'
14
+ class Flickr
15
+ include OmniAuth::Strategy
16
+ attr_accessor :api_key, :secret_key, :options
17
+
18
+ # error catching, based on OAuth2 callback
19
+ class CallbackError < StandardError
20
+ attr_accessor :error, :error_reason
21
+ def initialize(error, error_reason)
22
+ self.error = error
23
+ self.error_reason = error_reason
24
+ end
25
+ end
26
+
27
+ # @param [Rack Application] app standard middleware application parameter
28
+ # @param [String] api_key the application id as [registered on Flickr](http://www.flickr.com/services/apps/)
29
+ # @param [String] secret_key the application secret as [registered on Flickr](http://www.flickr.com/services/apps/)
30
+ # @option options ['read','write','delete] :scope ('read') the scope of your authorization request; must be `read` or 'write' or 'delete'
31
+ def initialize(app, api_key, secret_key, options = {})
32
+ super(app, :flickr)
33
+ @api_key = api_key
34
+ @secret_key = secret_key
35
+ @options = {:scope => 'read'}.merge(options)
36
+ end
37
+
38
+ protected
39
+
40
+ def request_phase
41
+ params = { :api_key => api_key, :perms => options[:scope] }
42
+ params[:api_sig] = flickr_sign(params)
43
+ query_string = params.collect{ |key,value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&')
44
+ redirect "http://flickr.com/services/auth/?#{query_string}"
45
+ end
46
+
47
+ def callback_phase
48
+ params = { :api_key => api_key, :method => 'flickr.auth.getToken', :frob => request.params['frob'], :format => 'json', :nojsoncallback => '1' }
49
+ params[:api_sig] = flickr_sign(params)
50
+
51
+ response = RestClient.get('http://api.flickr.com/services/rest/', { :params => params })
52
+ auth = MultiJson.decode(response.to_s)
53
+ raise CallbackError.new(auth['code'],auth['message']) if auth['stat'] == 'fail'
54
+
55
+ @user = auth['auth']['user']
56
+ @access_token = auth['auth']['token']['_content']
57
+
58
+ super
59
+ rescue CallbackError => e
60
+ fail!(:invalid_response, e)
61
+ end
62
+
63
+ def auth_hash
64
+ OmniAuth::Utils.deep_merge(super, {
65
+ 'uid' => @user['nsid'],
66
+ 'credentials' => { 'token' => @access_token },
67
+ 'user_info' => @user,
68
+ 'extra' => { 'user_hash' => @user }
69
+ })
70
+ end
71
+
72
+ def flickr_sign(params)
73
+ Digest::MD5.hexdigest(secret_key + params.sort{|a,b| a[0].to_s <=> b[0].to_s }.flatten.join)
74
+ end
75
+ end
76
+ end
77
+ end
@@ -22,6 +22,7 @@ module OmniAuth
22
22
  super(app, :windows_live, app_id, app_secret, options)
23
23
  options[:ssl] ||= true
24
24
  options[:locale] ||= 'en-us'
25
+ options[:force_nonprovisioned] = true unless app_id
25
26
  end
26
27
 
27
28
  protected
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oa-more
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- - beta2
10
- version: 0.2.0.beta2
4
+ prerelease: 6
5
+ version: 0.2.0.beta3
11
6
  platform: ruby
12
7
  authors:
13
8
  - Michael Bleigh
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-01-14 00:00:00 -06:00
13
+ date: 2011-02-03 00:00:00 -06:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -25,103 +20,98 @@ dependencies:
25
20
  requirements:
26
21
  - - "="
27
22
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 2
31
- - 0
32
- - beta2
33
- version: 0.2.0.beta2
23
+ version: 0.2.0.beta3
34
24
  type: :runtime
35
25
  prerelease: false
36
26
  version_requirements: *id001
37
27
  - !ruby/object:Gem::Dependency
38
- name: rake
28
+ name: rest-client
39
29
  requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.6.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: multi_json
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.2
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
51
+ requirement: &id004 !ruby/object:Gem::Requirement
40
52
  none: false
41
53
  requirements:
42
54
  - - ">="
43
55
  - !ruby/object:Gem::Version
44
- segments:
45
- - 0
46
56
  version: "0"
47
57
  type: :development
48
58
  prerelease: false
49
- version_requirements: *id002
59
+ version_requirements: *id004
50
60
  - !ruby/object:Gem::Dependency
51
61
  name: mg
52
- requirement: &id003 !ruby/object:Gem::Requirement
62
+ requirement: &id005 !ruby/object:Gem::Requirement
53
63
  none: false
54
64
  requirements:
55
65
  - - ~>
56
66
  - !ruby/object:Gem::Version
57
- segments:
58
- - 0
59
- - 0
60
- - 8
61
67
  version: 0.0.8
62
68
  type: :development
63
69
  prerelease: false
64
- version_requirements: *id003
70
+ version_requirements: *id005
65
71
  - !ruby/object:Gem::Dependency
66
72
  name: rspec
67
- requirement: &id004 !ruby/object:Gem::Requirement
73
+ requirement: &id006 !ruby/object:Gem::Requirement
68
74
  none: false
69
75
  requirements:
70
76
  - - ~>
71
77
  - !ruby/object:Gem::Version
72
- segments:
73
- - 1
74
- - 3
75
- - 0
76
78
  version: 1.3.0
77
79
  type: :development
78
80
  prerelease: false
79
- version_requirements: *id004
81
+ version_requirements: *id006
80
82
  - !ruby/object:Gem::Dependency
81
83
  name: webmock
82
- requirement: &id005 !ruby/object:Gem::Requirement
84
+ requirement: &id007 !ruby/object:Gem::Requirement
83
85
  none: false
84
86
  requirements:
85
87
  - - ~>
86
88
  - !ruby/object:Gem::Version
87
- segments:
88
- - 1
89
- - 3
90
- - 4
91
89
  version: 1.3.4
92
90
  type: :development
93
91
  prerelease: false
94
- version_requirements: *id005
92
+ version_requirements: *id007
95
93
  - !ruby/object:Gem::Dependency
96
94
  name: rack-test
97
- requirement: &id006 !ruby/object:Gem::Requirement
95
+ requirement: &id008 !ruby/object:Gem::Requirement
98
96
  none: false
99
97
  requirements:
100
98
  - - ~>
101
99
  - !ruby/object:Gem::Version
102
- segments:
103
- - 0
104
- - 5
105
- - 4
106
100
  version: 0.5.4
107
101
  type: :development
108
102
  prerelease: false
109
- version_requirements: *id006
103
+ version_requirements: *id008
110
104
  - !ruby/object:Gem::Dependency
111
105
  name: json
112
- requirement: &id007 !ruby/object:Gem::Requirement
106
+ requirement: &id009 !ruby/object:Gem::Requirement
113
107
  none: false
114
108
  requirements:
115
109
  - - ~>
116
110
  - !ruby/object:Gem::Version
117
- segments:
118
- - 1
119
- - 4
120
- - 3
121
111
  version: 1.4.3
122
112
  type: :development
123
113
  prerelease: false
124
- version_requirements: *id007
114
+ version_requirements: *id009
125
115
  description: Additional strategies for OmniAuth.
126
116
  email: michael@intridea.com
127
117
  executables: []
@@ -132,6 +122,7 @@ extra_rdoc_files: []
132
122
 
133
123
  files:
134
124
  - lib/omniauth/more.rb
125
+ - lib/omniauth/strategies/flickr.rb
135
126
  - lib/omniauth/strategies/windows_live/windowslivelogin.rb
136
127
  - lib/omniauth/strategies/windows_live.rb
137
128
  - README.rdoc
@@ -150,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
141
  requirements:
151
142
  - - ">="
152
143
  - !ruby/object:Gem::Version
153
- hash: 220420108562034819
144
+ hash: -2884158219464284428
154
145
  segments:
155
146
  - 0
156
147
  version: "0"
@@ -159,15 +150,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
150
  requirements:
160
151
  - - ">"
161
152
  - !ruby/object:Gem::Version
162
- segments:
163
- - 1
164
- - 3
165
- - 1
166
153
  version: 1.3.1
167
154
  requirements: []
168
155
 
169
156
  rubyforge_project:
170
- rubygems_version: 1.3.7
157
+ rubygems_version: 1.5.0
171
158
  signing_key:
172
159
  specification_version: 3
173
160
  summary: Additional strategies for OmniAuth.