omniauth-test 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,84 +1,45 @@
1
- require 'omniauth-oauth'
1
+ require 'omniauth/oauth'
2
2
  require 'multi_json'
3
- require 'omniauth/strategies/test'
4
- require 'rspec/rails'
5
-
3
+
6
4
  module OmniAuth
7
- module Strategies
8
- class Test < OmniAuth::Strategies::OAuth
9
- option :name, 'test'
10
-
11
- option :client_options, {:authorize_path => 'http://auth.cibplus.com/oauth/authorize',
12
- :site => 'http://auth.cibplus.com',
13
- :proxy => ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil}
14
-
15
- uid { access_token.params[:user_id] }
16
-
17
- info do
18
-
19
- {
20
- :nickname => raw_info['screen_name'],
21
- :name => raw_info['name'],
22
- :location => raw_info['location'],
23
- :image => image_url,
24
- :description => raw_info['description'],
25
- :urls => {
26
- 'Website' => raw_info['url'],
27
- 'Test' => "http://auth.cibplus.com/#{raw_info['screen_name']}",
28
- }
29
- }
30
- end
31
-
32
- extra do
33
- { :raw_info => raw_info }
34
- end
35
-
36
- def raw_info
37
- @raw_info ||= MultiJson.load(access_token.get('/1.1/account/verify_credentials.json?include_entities=false&skip_status=true').body)
38
- rescue ::Errno::ETIMEDOUT
39
- raise ::Timeout::Error
40
- end
41
-
42
- alias :old_request_phase :request_phase
43
-
44
- def request_phase
45
- %w[force_login lang screen_name].each do |v|
46
- if request.params[v]
47
- options[:authorize_params][v.to_sym] = request.params[v]
48
- end
49
- end
50
-
51
- %w[x_auth_access_type].each do |v|
52
- if request.params[v]
53
- options[:request_params][v.to_sym] = request.params[v]
54
- end
55
- end
56
-
57
- if request.params['use_authorize'] == 'true'
58
- options[:client_options][:authorize_path] = '/oauth/authorize'
59
- else
60
- options[:client_options][:authorize_path] = '/oauth/authenticate'
61
- end
62
-
63
- old_request_phase
64
- end
65
-
66
- private
67
-
68
- def image_url
69
- original_url = options[:secure_image_url] ? raw_info['profile_image_url_https'] : raw_info['profile_image_url']
70
- case options[:image_size]
71
- when 'mini'
72
- original_url.sub('normal', 'mini')
73
- when 'bigger'
74
- original_url.sub('normal', 'bigger')
75
- when 'original'
76
- original_url.sub('_normal', '')
77
- else
78
- original_url
79
- end
80
- end
81
-
82
- end
5
+ module Strategies
6
+ class Test < OAuth2
7
+
8
+ def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
9
+ client_options = {
10
+ :site => 'http://auth.cibplus.com',
11
+ :authorize_url => "http://auth.cibplus.com/oauth/authorize",
12
+ :access_token_url => "http://auth.cibplus.com/oauth/token"
13
+ }
14
+ super(app, :test, api_key, secret_key, client_options, &block)
15
+ end
16
+
17
+ protected
18
+
19
+ def user_data
20
+ #@data ||= MultiJson.decode(@access_token.get("/auth/my_strategy/user.json"))
21
+ end
22
+
23
+ def request_phase
24
+ options[:scope] ||= "read"
25
+ super
26
+ end
27
+
28
+ def user_hash
29
+ user_data
30
+ end
31
+
32
+ def auth_hash
33
+ OmniAuth::Utils.deep_merge(super, {
34
+ 'uid' => user_data["uid"],
35
+ 'user_info' => user_data['user_info'],
36
+ 'extra' => {
37
+ 'admin' => user_data['extra']['admin'],
38
+ 'first_name' => user_data['extra']['first_name'],
39
+ 'last_name' => user_data['extra']['last_name'],
40
+ }
41
+ })
42
+ end
83
43
  end
84
- end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module OmniauthTest
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: