omniauth-campus 0.5.9 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9f430848d7a3c9fb3b749f702dfa72f6835d13c
4
- data.tar.gz: ef1b240908d2aa9c677fd297006d52836f7dbd9e
3
+ metadata.gz: 7744bb8ce6c6137b8a4aaaaf8f76eaa0cb5913be
4
+ data.tar.gz: f9058de3aaccee16fbd4144845a2543b22ff8dc0
5
5
  SHA512:
6
- metadata.gz: 57aa1b0fa61831d63046ec0a9edadb633f83326f7a4761ae4d296f2a5d3b43a3a1a9948fb69954abd1ca1ff77463d6edd9c0a108ff2d1b28feb583f4ab6a0a1c
7
- data.tar.gz: 9f4edf8b516030280fb7adcd8ad6bf77a39eb004c5dbc53a11921bb7ae474752d11e166ad6416556dcd69852219235b293a3ce98d0772e97f12ebfe85b3e162b
6
+ metadata.gz: 57106fbdb104c035894c9e1e2ed4f8313a6188f103eb355500080c54c17ad63b9fcdb2dd38806c56bf655933ae6b75092c614eda25202815aaeab598445b79e0
7
+ data.tar.gz: 6d10dcb69500cc56fedd148d4cb9b6767ca36ab2ed563420a324490cf2194228a9e82a6eecdc97d6e31030582b73c69606f3675fefa8357bec74cd778961c52a
Binary file
@@ -1,6 +1,6 @@
1
1
  module Omniauth
2
2
  module Campus
3
- VERSION = "0.5.9"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
6
6
 
Binary file
@@ -1,4 +1,4 @@
1
- require "omniauth"
1
+ require "omniauth-oauth2"
2
2
  require 'multi_json'
3
3
  require 'faraday'
4
4
  require 'net/http'
@@ -12,21 +12,26 @@ require 'uri'
12
12
  module OmniAuth
13
13
  module Strategies
14
14
  # Your code goes here...
15
- class Campus
16
- include OmniAuth::Strategy
15
+ class Campus < OmniAuth::Strategies::OAuth2
17
16
 
18
- args [:client_id, :client_secret, :endpoint]
17
+ DEFAULT_RESPONSE_TYPE = 'code'
18
+ DEFAULT_GRANT = 'authorization_code'
19
+
20
+ option :name, 'campus'
21
+ args [:client_id, :client_secret]
19
22
  #option :consumer_key, "YzjVHuk8xoXCTcNwYg57yiCW5w59tucC"
20
23
  #option :consumer_secret, "ZDrWuDsunNkRroU5psb6QyMmT86XkYST"
21
24
  option :client_options, {
22
- client_id: nil,
23
- client_secret: nil,
25
+ token_url: '/oauth/access_token',
26
+ authorize_url: '/oauth/authorize',
24
27
  #request_token_path: '/oauth/request_token',
25
- endpoint: 'https://community3dev.devcloud.acquia-sites.com/api'
28
+ site: 'http://community3dev.devcloud.acquia-sites.com/api'
26
29
  }
27
30
 
28
31
  option :fields, [:name, :email]
29
32
 
33
+ attr_accessor :access_token
34
+
30
35
 
31
36
  #site' 'http://community3dev.devcloud.acquia-sites.com/api'
32
37
 
@@ -38,21 +43,6 @@ module OmniAuth
38
43
  # }
39
44
  #
40
45
 
41
- def request_phase
42
- form = OmniAuth::Form.new(:title => "User Info", :url => callback_path)
43
- options.fields.each do |field|
44
- form.text_field field.to_s.capitalize.gsub("_", " "), field.to_s
45
- end
46
- form.button "Sign In"
47
- form.to_response
48
- end
49
-
50
- def callback_phase
51
- return fail!(:invalid_credentials) if !authentication_response
52
- return fail!(:invalid_credentials) if authentication_response.code.to_i >= 400
53
- super
54
- end
55
-
56
46
 
57
47
  uid {raw_info['uid']}
58
48
 
@@ -63,41 +53,12 @@ module OmniAuth
63
53
  end
64
54
 
65
55
  def raw_info
66
- @raw_info ||= MultiJson.decode(access_token.get(@authentication_response).body )
67
- end
68
-
69
- def api_uri
70
- options.endpoint
71
- end
72
-
73
- def name
74
- request['name']
75
- end
76
-
77
- def email
78
- request['email']
79
- end
80
-
81
- def authentication_response
82
- unless @authentication_response
83
- return unless name && email
84
-
85
- uri = URI(api_uri)
86
- http = Net::HTTP.new(uri.host, uri.port)
87
- if uri.scheme == 'https'
88
- http.use_ssl = true
89
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
90
- end
91
-
92
- req = Net::HTTP::Get.new(uri.request_uri)
93
- req.basic_auth name, email
94
- @authentication_response = http.request(req)
95
- end
96
-
97
- @authentication_response
56
+ @raw_info ||= MultiJson.decode(access_token.get('/me').body )
98
57
  end
99
58
 
100
59
  end
101
60
  end
102
61
  end
103
62
 
63
+
64
+
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.5.9
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - johnvehr