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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7c4cef6ca65e57faf61483baad188235d685258
|
4
|
+
data.tar.gz: 0cbfa5068f923e53c58fd0e95519dae5d21b9b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65876abb1bb8643dcac208c620c024ce6e9893331269f75f63e782077eccd3d3cbdf4c36c98d417793fc2044759044f07e39b9f9374da03a9f756da425ede5c6
|
7
|
+
data.tar.gz: 19b2209d9363feef5af109f6325b32b672a17ee9e61733af139ac5d46af9fd2771a27bac69548f1a7b5eeeae9066dfb4e3159b3941ed5285926e3663215892a6
|
Binary file
|
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
|
-
|
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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
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
|
-
|
38
|
-
|
81
|
+
extra do
|
82
|
+
{'access_token' => access_token}
|
39
83
|
end
|
84
|
+
|
40
85
|
end
|
41
86
|
end
|
42
87
|
end
|