omniauth-campus 0.0.9 → 0.0.10
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: 07307aa42fc4b79524cd5db1993e6447972ffbea
|
4
|
+
data.tar.gz: 23d27caf8ef6098451d502e4e800819162c09150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1b31304479c9a7502d9852bff38f4a6e097bee94473a1038a336ee1e311f3e318636a50fa34a179b0846ed685f03b5f3325f8606c9dd758e3485cbf524ea838
|
7
|
+
data.tar.gz: 1c9c616afc306eb077665eec089f6ffa4aa56ce1b8cf0b1826656a1283f285d08629af30a8259896b42c2066f83486fafa3777972b2d95ca4a6cf677626a75ed
|
Binary file
|
@@ -3,6 +3,7 @@ require 'omniauth'
|
|
3
3
|
require 'multi_json'
|
4
4
|
require 'openssl'
|
5
5
|
require 'uri'
|
6
|
+
require 'net/http'
|
6
7
|
#require 'rack/utils'
|
7
8
|
|
8
9
|
module OmniAuth
|
@@ -11,43 +12,70 @@ module OmniAuth
|
|
11
12
|
class Campus
|
12
13
|
include OmniAuth::Strategy
|
13
14
|
|
15
|
+
args ['http://community3dev.devcloud.acquia-sites.com/api']
|
14
16
|
|
15
|
-
|
17
|
+
option :title, "Http basic"
|
18
|
+
option :headers, {}
|
16
19
|
|
17
|
-
|
18
|
-
option :consumer_key, nil
|
19
|
-
option :consumer_secret, nil
|
20
|
-
option :client_options, {
|
21
|
-
:site => 'http://community3dev.devcloud.acquia-sites.com/api',
|
22
|
-
:authorize_url => 'https://www.vistacampus.org/login/oauth/authorize',
|
23
|
-
:token_url => 'https://www.vistacampus.org/login/oauth/access_token'
|
20
|
+
#site: 'http://community3dev.devcloud.acquia-sites.com/api'
|
24
21
|
|
25
|
-
|
22
|
+
#option :client_options, {
|
23
|
+
# :site => 'http://community3dev.devcloud.acquia-sites.com/api',
|
24
|
+
# :authorize_url => 'https://www.vistacampus.org/login/oauth/authorize',
|
25
|
+
# :token_url => 'https://www.vistacampus.org/login/oauth/access_token'
|
26
|
+
#
|
27
|
+
# }
|
28
|
+
#
|
26
29
|
|
27
30
|
def request_phase
|
28
|
-
|
31
|
+
form = OmniAuth::Form.new(:title => options.title, :url => callback_path)
|
32
|
+
text_field 'Username', 'username'
|
33
|
+
password_field 'Password', 'password'
|
34
|
+
form.button "Sign In"
|
35
|
+
form.to_response
|
29
36
|
end
|
30
37
|
|
31
38
|
|
39
|
+
def callback_phase
|
40
|
+
return fail!(:invalid_credentials) if !authentication_response
|
41
|
+
return fail!(:invalid_credentials) if authentication_response.code.to_i >= 400
|
42
|
+
super
|
43
|
+
end
|
32
44
|
|
33
|
-
|
45
|
+
protected
|
34
46
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
47
|
+
# by default we use static uri. If dynamic uri is required, override
|
48
|
+
# this method.
|
49
|
+
def api_uri
|
50
|
+
'http://community3dev.devcloud.acquia-sites.com/api'
|
51
|
+
end
|
41
52
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
46
|
-
end
|
53
|
+
def username
|
54
|
+
request['username']
|
55
|
+
end
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
|
57
|
+
def password
|
58
|
+
request['password']
|
59
|
+
end
|
60
|
+
|
61
|
+
def authentication_response
|
62
|
+
unless @authentication_response
|
63
|
+
return unless username && password
|
64
|
+
|
65
|
+
uri = URI(api_uri)
|
66
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
67
|
+
if uri.scheme == 'https'
|
68
|
+
http.use_ssl = true
|
69
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
70
|
+
end
|
71
|
+
|
72
|
+
req = Net::HTTP::Get.new(uri.request_uri)
|
73
|
+
req.basic_auth username, password
|
74
|
+
@authentication_response = http.request(req)
|
75
|
+
end
|
76
|
+
|
77
|
+
@authentication_response
|
78
|
+
end
|
51
79
|
|
52
80
|
end
|
53
81
|
end
|
Binary file
|