omniauth-campus 0.0.4 → 0.0.5

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: 4c4335ee1dab94f5e073335f9c867245c9a57d62
4
- data.tar.gz: 04e9f3bd91d4e19d514b4dcfef067244d2a75eb9
3
+ metadata.gz: d7c4cef6ca65e57faf61483baad188235d685258
4
+ data.tar.gz: 0cbfa5068f923e53c58fd0e95519dae5d21b9b92
5
5
  SHA512:
6
- metadata.gz: c84a883ef893c6b73ddd421821286f13527b3220867220191eff24006e28b779f59a103eece5c964b501dc427c426f40352febc287ba07888d3dfc734f6fed6c
7
- data.tar.gz: 50e00747220c596e4d2e94f2a6a5aea753c8504a2a907ab60406f92afdcb8308b3855537dcd345731c638f5dd6f75d66d4cd965a58b6e418645106f2a01c0abd
6
+ metadata.gz: 65876abb1bb8643dcac208c620c024ce6e9893331269f75f63e782077eccd3d3cbdf4c36c98d417793fc2044759044f07e39b9f9374da03a9f756da425ede5c6
7
+ data.tar.gz: 19b2209d9363feef5af109f6325b32b672a17ee9e61733af139ac5d46af9fd2771a27bac69548f1a7b5eeeae9066dfb4e3159b3941ed5285926e3663215892a6
Binary file
@@ -1,6 +1,6 @@
1
1
  module Omniauth
2
2
  module Campus
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
6
6
 
Binary file
@@ -11,32 +11,77 @@ module Omniauth
11
11
  class Campus
12
12
  include OmniAuth::Strategy
13
13
 
14
- option :name, 'campus'
15
14
 
16
- option :client_options, {
17
- site: 'http://community3dev.devcloud.acquia-sites.com/api'
18
- }
19
- option :client_id, nil
20
- option :client_secret, nil
15
+ #site: 'http://community3dev.devcloud.acquia-sites.com/api'
21
16
 
22
- uid{ raw_info['id'] }
17
+ args [:consumer_key, :consumer_secret]
18
+ option :consumer_key, nil
19
+ option :consumer_secret, nil
20
+ option :client_options, {}
21
+ option :open_timeout, 30
22
+ option :read_timeout, 30
23
+ option :authorize_params, {}
24
+ option :request_params, {}
23
25
 
24
- info do
25
- {
26
- :name => raw_info['name'],
27
- :email => raw_info['email']
28
- }
26
+ attr_reader :access_tokens
27
+
28
+ def consumer
29
+ consumer = ::Campus::Consumer.new(options.consumer_key, options.consumer_secret, options.client_options)
30
+ consumer.http.open_timeout = options.open_timeout if options.open_timeout
31
+ consumer.http.read_timeout = options.read_timeout if options.read_timeout
32
+ end
33
+
34
+ def request_phase
35
+ request_token = consumer.get_request_token({:oauth_callback => callback_url}, options.request_params)
36
+ session['campus'] ||= {}
37
+ session['campus'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
38
+
39
+ if request_token.callback_confirmed?
40
+ redirect request_token.authorize_url(options[:authorize_params])
41
+ else
42
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url))
43
+ end
44
+
45
+ rescue ::Timeout::Error => e
46
+ fail!(:timeout, e)
47
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
48
+ fail!(:service_unavailable, e)
49
+ end
50
+
51
+ def callback_phase
52
+ raise OmniAuth::NoSessionError.new("Session Expired") if session['campus'].nil?
53
+
54
+ request_token = ::Campus::RequestToken.new(consumer, session['campus'][name.to_s].delete('request_token'), session['campus'][name.to_s].delete('request_secret'))
55
+
56
+ opts = {}
57
+ if session['campus'][name.to_s]['callback_confirmed']
58
+ opts[:oauth_verifier] = request['oauth_verifier']
59
+ else
60
+ opts[:oauth_callback] = callback_url
61
+ end
62
+
63
+ @access_token = request_token.get_access_token(opts)
64
+ super
65
+ rescue ::Timeout::Error => e
66
+ fail!(:timeout, e)
67
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
68
+ fail!(:service_unavailable, e)
69
+ rescue ::Campus::Unauthorized => e
70
+ fail!(:invalid_credentials, e)
71
+ rescue ::MultiJson::DecodeError => e
72
+ fail!(:invalid_response, e)
73
+ rescue ::OmniAuth::NoSessionError => e
74
+ fail!(:session_expired, e)
29
75
  end
30
76
 
31
- extra do
32
- {
33
- 'raw_info' => raw_info
34
- }
77
+ credentials do
78
+ {'token' => access_token.token, 'secret' => access_token.secret}
35
79
  end
36
80
 
37
- def raw_info
38
- @raw_info ||= access_token.get('/me').parsed
81
+ extra do
82
+ {'access_token' => access_token}
39
83
  end
84
+
40
85
  end
41
86
  end
42
87
  end
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: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - johnvehr