omniauth-campus 1.9 → 2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bee7fea4d1e5c1c8fa43c8ed004fedd63a13bf9e
4
- data.tar.gz: 34724feb16cd3238eb7582c96726e0657b3db062
3
+ metadata.gz: 8dc60d7df8ef6f6ef8545d6f77a4ae7dd6236d79
4
+ data.tar.gz: e7a941aab44da8085dfb8bc8cf7e8855b75b323f
5
5
  SHA512:
6
- metadata.gz: c07b0979f864165111181fa0c807bae9d1764ebcc0bbcd02836080142cb96d2246be6951793a5f6b918a7980bfea4b3d881c7514cd728ab1e505e51617de4112
7
- data.tar.gz: 6e63ae8d8fc42361e036b73a4bc61f2c3224e38f408970f2d7d21f33616471ab197246070f7162c9a3089c9462f3044e49e7db938e0a7caf6945e1bef2fae465
6
+ metadata.gz: eb2903d75b3be39fb800e25f6d5a751f92e823c8a9399a941764793e34c646426184f54c03ca06221539089dd374436da14c6ac313122c53628dbfd577f928dd
7
+ data.tar.gz: 0fee707b02c1475b9ff42512236844988487aefe5e7c314650c5a97ba539ee355da772f5b4badd36baa3b5467e4d9b2e0566fc89d30758e59c6050a7b9ca1c83
@@ -1,6 +1,6 @@
1
1
  module Omniauth
2
2
  module Campus
3
- VERSION = "1.9"
3
+ VERSION = "2.0"
4
4
  end
5
5
  end
6
6
 
@@ -19,32 +19,69 @@ module OmniAuth
19
19
  option :consumer_secret, nil
20
20
 
21
21
  option :client_options, {
22
- :site => "http://dev-oauth-test.gotpantheon.com/myawesomejson",
22
+ :site => "http://dev-oauth-test.gotpantheon.com",
23
23
  :proxy => ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil
24
24
  }
25
25
 
26
26
  option :name, "campus"
27
27
 
28
- def request_phase
29
- %w[force_login lang screen_name].each do |v|
30
- if request.params[v]
31
- options[:authorize_params][v.to_sym] = request.params[v]
32
- end
33
- end
28
+ attr_reader :access_token
29
+ #option :client_options, {:authorize_path => '/oauth/authenticate'
30
+ #:site => 'http://dev-oauth-test.gotpantheon.com/myawesomejson',
31
+ #:proxy => ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil}
32
+
33
+ def consumer
34
+ consumer = ::OAuth::Consumer.new(options.consumer_key, options.consumer_secret, options.client_options)
35
+ consumer.http.open_timeout = options.open_timeout if options.open_timeout
36
+ consumer.http.read_timeout = options.read_timeout if options.read_timeout
37
+ consumer
38
+ end
34
39
 
35
- %w[x_auth_access_type].each do |v|
36
- if request.params[v]
37
- options[:request_params][v.to_sym] = request.params[v]
38
- end
40
+ def request_phase
41
+ request_token = consumer.get_request_token({:oauth_callback => callback_url}, options.request_params)
42
+ session['oauth'] ||= {}
43
+ session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
44
+
45
+ if request_token.callback_confirmed?
46
+ redirect request_token.authorize_url(options[:authorize_params])
47
+ else
48
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url))
39
49
  end
40
50
 
41
- if request.params['use_authorize'] == 'true'
42
- options[:client_options][:authorize_path] = '/oauth/authorize'
51
+ rescue ::Timeout::Error => e
52
+ fail!(:timeout, e)
53
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
54
+ fail!(:service_unavailable, e)
55
+ end
56
+
57
+ def callback_phase
58
+ raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil?
59
+
60
+ request_token = ::OAuth::RequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret'))
61
+
62
+ opts = {}
63
+ if session['oauth'][name.to_s]['callback_confirmed']
64
+ opts[:oauth_verifier] = request['oauth_verifier']
43
65
  else
44
- options[:client_options][:authorize_path] = '/oauth/authenticate'
66
+ opts[:oauth_callback] = callback_url
45
67
  end
46
68
 
69
+ @access_token = request_token.get_access_token(opts)
70
+ super
71
+ rescue ::Timeout::Error => e
72
+ fail!(:timeout, e)
73
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
74
+ fail!(:service_unavailable, e)
75
+ rescue ::OAuth::Unauthorized => e
76
+ fail!(:invalid_credentials, e)
77
+ rescue ::MultiJson::DecodeError => e
78
+ fail!(:invalid_response, e)
79
+ rescue ::OmniAuth::NoSessionError => e
80
+ fail!(:session_expired, e)
81
+ end
47
82
 
83
+ credentials do
84
+ {'token' => access_token.token, 'secret' => access_token.secret}
48
85
  end
49
86
 
50
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-campus
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.9'
4
+ version: '2.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - johnvehr