omniauth-myvr 0.0.2 → 0.0.4
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 +4 -4
- data/example/config.ru +1 -1
- data/lib/omniauth/strategies/myvr.rb +177 -177
- data/lib/omniauth_myvr.rb +2 -2
- data/omniauth-myvr.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5628f6edef469d955e3dd28ac5489ad566fdb50d
|
4
|
+
data.tar.gz: 9a5ca5ed3183d23ed78252b9c3f219625bf3ad26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed21c07fcc864aba84088561b3df7ff59fc3365f73ad2dbbd6d4ed5eb0ae2cae2814c4ba98cfac3bcc7d8970363c33f0852ae6010a8d096ffac2950031294bb4
|
7
|
+
data.tar.gz: 6425e315fa6970f56a9913abb47484382f222dd6e833fd785f3e35ae438dcde6e3ed0ed5353a4d8bf805c041c47934bc626d27710cf4ed4e811d748367a00fd5
|
data/example/config.ru
CHANGED
@@ -5,7 +5,7 @@ require 'uri'
|
|
5
5
|
|
6
6
|
module OmniAuth
|
7
7
|
module Strategies
|
8
|
-
class
|
8
|
+
class Myvr < OmniAuth::Strategies::OAuth2
|
9
9
|
BASE_SCOPE_URL = "https://api.myvr.com/auth/"
|
10
10
|
BASE_SCOPES = %w[profile email openid]
|
11
11
|
DEFAULT_SCOPE = "email,profile"
|
@@ -30,184 +30,184 @@ module OmniAuth
|
|
30
30
|
option :authorized_client_ids, []
|
31
31
|
|
32
32
|
option :client_options, {
|
33
|
-
:site => 'https://
|
34
|
-
:authorize_url => '/
|
35
|
-
:token_url => '/
|
33
|
+
:site => 'https://myvr.com/',
|
34
|
+
:authorize_url => '/connect/oauth/auth',
|
35
|
+
:token_url => '/connect/oauth/token'
|
36
36
|
}
|
37
37
|
|
38
|
-
def authorize_params
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
uid { raw_info['sub'] || verified_email }
|
56
|
-
|
57
|
-
info do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
extra do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
def raw_info
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
def raw_friend_info(id)
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
def raw_image_info(id)
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
def custom_build_access_token
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
end
|
125
|
-
alias_method :build_access_token, :custom_build_access_token
|
126
|
-
|
127
|
-
private
|
128
|
-
|
129
|
-
def callback_url
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
def get_token_options(redirect_uri)
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
def prune!(hash)
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
def verified_email
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
def image_url
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
164
|
-
|
165
|
-
def image_size_opts_passed?
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
def image_params
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
def strip_unnecessary_query_parameters(query_parameters)
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
end
|
195
|
-
|
196
|
-
def verify_token(access_token)
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
end
|
202
|
-
|
203
|
-
def verify_hd(access_token)
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
end
|
38
|
+
# def authorize_params
|
39
|
+
# super.tap do |params|
|
40
|
+
# options[:authorize_options].each do |k|
|
41
|
+
# params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# raw_scope = params[:scope] || DEFAULT_SCOPE
|
45
|
+
# scope_list = raw_scope.split(" ").map {|item| item.split(",")}.flatten
|
46
|
+
# scope_list.map! { |s| s =~ /^https?:\/\// || BASE_SCOPES.include?(s) ? s : "#{BASE_SCOPE_URL}#{s}" }
|
47
|
+
# params[:scope] = scope_list.join(" ")
|
48
|
+
# params[:access_type] = 'offline' if params[:access_type].nil?
|
49
|
+
# params['openid.realm'] = params.delete(:openid_realm) unless params[:openid_realm].nil?
|
50
|
+
#
|
51
|
+
# session['omniauth.state'] = params[:state] if params['state']
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
|
55
|
+
# uid { raw_info['sub'] || verified_email }
|
56
|
+
#
|
57
|
+
# info do
|
58
|
+
# prune!({
|
59
|
+
# :name => raw_info['name'],
|
60
|
+
# :email => verified_email,
|
61
|
+
# :first_name => raw_info['given_name'],
|
62
|
+
# :last_name => raw_info['family_name'],
|
63
|
+
# :image => image_url,
|
64
|
+
# :urls => {
|
65
|
+
# 'Google' => raw_info['profile']
|
66
|
+
# }
|
67
|
+
# })
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# extra do
|
71
|
+
# hash = {}
|
72
|
+
# hash[:id_token] = access_token['id_token']
|
73
|
+
# if !options[:skip_jwt] && !access_token['id_token'].nil?
|
74
|
+
# hash[:id_info] = JWT.decode(
|
75
|
+
# access_token['id_token'], nil, false, {
|
76
|
+
# :verify_iss => true,
|
77
|
+
# 'iss' => 'accounts.google.com',
|
78
|
+
# :verify_aud => true,
|
79
|
+
# 'aud' => options.client_id,
|
80
|
+
# :verify_sub => false,
|
81
|
+
# :verify_expiration => true,
|
82
|
+
# :verify_not_before => true,
|
83
|
+
# :verify_iat => true,
|
84
|
+
# :verify_jti => false,
|
85
|
+
# :leeway => options[:jwt_leeway]
|
86
|
+
# }).first
|
87
|
+
# end
|
88
|
+
# hash[:raw_info] = raw_info unless skip_info?
|
89
|
+
# hash[:raw_friend_info] = raw_friend_info(raw_info['sub']) unless skip_info? || options[:skip_friends]
|
90
|
+
# hash[:raw_image_info] = raw_image_info(raw_info['sub']) unless skip_info? || options[:skip_image_info]
|
91
|
+
# prune! hash
|
92
|
+
# end
|
93
|
+
#
|
94
|
+
# def raw_info
|
95
|
+
# @raw_info ||= access_token.get('https://www.googleapis.com/plus/v1/people/me/openIdConnect').parsed
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# def raw_friend_info(id)
|
99
|
+
# @raw_friend_info ||= access_token.get("https://www.googleapis.com/plus/v1/people/#{id}/people/visible").parsed
|
100
|
+
# end
|
101
|
+
#
|
102
|
+
# def raw_image_info(id)
|
103
|
+
# @raw_image_info ||= access_token.get("https://www.googleapis.com/plus/v1/people/#{id}?fields=image").parsed
|
104
|
+
# end
|
105
|
+
#
|
106
|
+
# def custom_build_access_token
|
107
|
+
# access_token =
|
108
|
+
# if request.xhr? && request.params['code']
|
109
|
+
# verifier = request.params['code']
|
110
|
+
# client.auth_code.get_token(verifier, get_token_options('postmessage'), deep_symbolize(options.auth_token_params || {}))
|
111
|
+
# elsif request.params['code'] && request.params['redirect_uri']
|
112
|
+
# verifier = request.params['code']
|
113
|
+
# redirect_uri = request.params['redirect_uri']
|
114
|
+
# client.auth_code.get_token(verifier, get_token_options(redirect_uri), deep_symbolize(options.auth_token_params || {}))
|
115
|
+
# elsif verify_token(request.params['access_token'])
|
116
|
+
# ::OAuth2::AccessToken.from_hash(client, request.params.dup)
|
117
|
+
# else
|
118
|
+
# verifier = request.params["code"]
|
119
|
+
# client.auth_code.get_token(verifier, get_token_options(callback_url), deep_symbolize(options.auth_token_params))
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
# verify_hd(access_token)
|
123
|
+
# access_token
|
124
|
+
# end
|
125
|
+
# alias_method :build_access_token, :custom_build_access_token
|
126
|
+
#
|
127
|
+
# private
|
128
|
+
#
|
129
|
+
# def callback_url
|
130
|
+
# options[:redirect_uri] || (full_host + script_name + callback_path)
|
131
|
+
# end
|
132
|
+
#
|
133
|
+
# def get_token_options(redirect_uri)
|
134
|
+
# { :redirect_uri => redirect_uri }.merge(token_params.to_hash(:symbolize_keys => true))
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
# def prune!(hash)
|
138
|
+
# hash.delete_if do |_, v|
|
139
|
+
# prune!(v) if v.is_a?(Hash)
|
140
|
+
# v.nil? || (v.respond_to?(:empty?) && v.empty?)
|
141
|
+
# end
|
142
|
+
# end
|
143
|
+
#
|
144
|
+
# def verified_email
|
145
|
+
# raw_info['email_verified'] ? raw_info['email'] : nil
|
146
|
+
# end
|
147
|
+
#
|
148
|
+
# def image_url
|
149
|
+
# return nil unless raw_info['picture']
|
150
|
+
#
|
151
|
+
# u = URI.parse(raw_info['picture'].gsub('https:https', 'https'))
|
152
|
+
#
|
153
|
+
# path_index = u.path.to_s.index('/photo.jpg')
|
154
|
+
#
|
155
|
+
# if path_index && image_size_opts_passed?
|
156
|
+
# u.path.insert(path_index, image_params)
|
157
|
+
# u.path = u.path.gsub('//', '/')
|
158
|
+
# end
|
159
|
+
#
|
160
|
+
# u.query = strip_unnecessary_query_parameters(u.query)
|
161
|
+
#
|
162
|
+
# u.to_s
|
163
|
+
# end
|
164
|
+
#
|
165
|
+
# def image_size_opts_passed?
|
166
|
+
# !!(options[:image_size] || options[:image_aspect_ratio])
|
167
|
+
# end
|
168
|
+
#
|
169
|
+
# def image_params
|
170
|
+
# image_params = []
|
171
|
+
# if options[:image_size].is_a?(Integer)
|
172
|
+
# image_params << "s#{options[:image_size]}"
|
173
|
+
# elsif options[:image_size].is_a?(Hash)
|
174
|
+
# image_params << "w#{options[:image_size][:width]}" if options[:image_size][:width]
|
175
|
+
# image_params << "h#{options[:image_size][:height]}" if options[:image_size][:height]
|
176
|
+
# end
|
177
|
+
# image_params << 'c' if options[:image_aspect_ratio] == 'square'
|
178
|
+
#
|
179
|
+
# '/' + image_params.join('-')
|
180
|
+
# end
|
181
|
+
#
|
182
|
+
# def strip_unnecessary_query_parameters(query_parameters)
|
183
|
+
# # strip `sz` parameter (defaults to sz=50) which overrides `image_size` options
|
184
|
+
# return nil if query_parameters.nil?
|
185
|
+
#
|
186
|
+
# params = CGI.parse(query_parameters)
|
187
|
+
# stripped_params = params.delete_if { |key| key == "sz" }
|
188
|
+
#
|
189
|
+
# # don't return an empty Hash since that would result
|
190
|
+
# # in URLs with a trailing ? character: http://image.url?
|
191
|
+
# return nil if stripped_params.empty?
|
192
|
+
#
|
193
|
+
# URI.encode_www_form(stripped_params)
|
194
|
+
# end
|
195
|
+
#
|
196
|
+
# def verify_token(access_token)
|
197
|
+
# return false unless access_token
|
198
|
+
# raw_response = client.request(:get, 'https://www.googleapis.com/oauth2/v3/tokeninfo',
|
199
|
+
# params: { access_token: access_token }).parsed
|
200
|
+
# raw_response['aud'] == options.client_id || options.authorized_client_ids.include?(raw_response['aud'])
|
201
|
+
# end
|
202
|
+
#
|
203
|
+
# def verify_hd(access_token)
|
204
|
+
# return true unless options.hd
|
205
|
+
# @raw_info ||= access_token.get('https://www.googleapis.com/plus/v1/people/me/openIdConnect').parsed
|
206
|
+
# allowed_hosted_domains = Array(options.hd)
|
207
|
+
#
|
208
|
+
# raise CallbackError.new(:invalid_hd, "Invalid Hosted Domain") unless allowed_hosted_domains.include? @raw_info['hd']
|
209
|
+
# true
|
210
|
+
# end
|
211
211
|
end
|
212
212
|
end
|
213
213
|
end
|
data/lib/omniauth_myvr.rb
CHANGED
data/omniauth-myvr.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "omniauth-myvr"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.4"
|
7
7
|
s.authors = ["CJ Avilla"]
|
8
8
|
s.email = ["cjavilla@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/w1zeman1p/omniauth-myvr"
|