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: 543c9b991a619cf33d3ee80029af3a39ee5d6f89
4
- data.tar.gz: f739fd12d382629331964534a49be4aa5849cbd3
3
+ metadata.gz: 07307aa42fc4b79524cd5db1993e6447972ffbea
4
+ data.tar.gz: 23d27caf8ef6098451d502e4e800819162c09150
5
5
  SHA512:
6
- metadata.gz: 0f67dea07b701883e9a828d8f7dac1cfa1cef83276569bd3d44c5f07abe7fdb3adaab8f53828dfc17aefde82e4c01a2432a64dfce3d0d0025af89b3c727e7936
7
- data.tar.gz: 1855b0230d07868bf4d25fc1ec843a9946ca37a4d055db59a54f6c2381094e173b2ad66e581643adde432bb76977aff52ce6b43ecd4c083aa3fc1e156cbad6c3
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
- #site: 'http://community3dev.devcloud.acquia-sites.com/api'
17
+ option :title, "Http basic"
18
+ option :headers, {}
16
19
 
17
- args [:consumer_key, :consumer_secret]
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
- super
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
- uid{ raw_info['id'] }
45
+ protected
34
46
 
35
- info do
36
- {
37
- :name => raw_info['name'],
38
- :email => raw_info['email']
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
- extra do
43
- {
44
- 'raw_info' => raw_info
45
- }
46
- end
53
+ def username
54
+ request['username']
55
+ end
47
56
 
48
- def raw_info
49
- @raw_info ||= access_token.get('/me').parsed
50
- end
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
@@ -1,6 +1,6 @@
1
1
  module Omniauth
2
2
  module Campus
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
  end
5
5
  end
6
6
 
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.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - johnvehr