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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7744bb8ce6c6137b8a4aaaaf8f76eaa0cb5913be
|
4
|
+
data.tar.gz: f9058de3aaccee16fbd4144845a2543b22ff8dc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57106fbdb104c035894c9e1e2ed4f8313a6188f103eb355500080c54c17ad63b9fcdb2dd38806c56bf655933ae6b75092c614eda25202815aaeab598445b79e0
|
7
|
+
data.tar.gz: 6d10dcb69500cc56fedd148d4cb9b6767ca36ab2ed563420a324490cf2194228a9e82a6eecdc97d6e31030582b73c69606f3675fefa8357bec74cd778961c52a
|
Binary file
|
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
|
-
|
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
|
-
|
23
|
-
|
25
|
+
token_url: '/oauth/access_token',
|
26
|
+
authorize_url: '/oauth/authorize',
|
24
27
|
#request_token_path: '/oauth/request_token',
|
25
|
-
|
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(
|
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
|
+
|