identity-toolkit-ruby-client 0.1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -1
- data/lib/gitkit_client.rb +12 -14
- data/lib/rpc_helper.rb +4 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f704bf2aa7be011903fd425170f12aaa67577b6
|
4
|
+
data.tar.gz: d983143a7985d766db8b915c64a9997dc3c691fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d990ca18b3679a3d53ed9b9d352cb97e4e1c7d90babff6421d91775d0fa7a0d87a3bec6587237ae73b04c207d66f4f890108c582293e1305115140528d83f295
|
7
|
+
data.tar.gz: 7372e91455d36a8ab393eb31b01e5510289ac7f32771bcf80a7b189280df51f29b06a483dddb1d782745a20224ebb3f7bc4b5d476b4b200377fb97b62da8487f
|
data/README.rdoc
CHANGED
data/lib/gitkit_client.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
require 'addressable/uri'
|
16
16
|
require 'jwt'
|
17
|
-
require '
|
17
|
+
require 'multi_json'
|
18
18
|
require 'rpc_helper'
|
19
19
|
require 'uri'
|
20
20
|
|
@@ -26,7 +26,7 @@ module GitkitLib
|
|
26
26
|
#
|
27
27
|
# @param [String] file file name of the json-format config
|
28
28
|
def self.create_from_config_file(file)
|
29
|
-
config =
|
29
|
+
config = MultiJson.load File.open(file, 'rb') { |io| io.read }
|
30
30
|
p12key = File.open(config['serviceAccountPrivateKeyFile'], 'rb') {
|
31
31
|
|io| io.read }
|
32
32
|
new(
|
@@ -42,7 +42,7 @@ module GitkitLib
|
|
42
42
|
# @param [String] client_id Google oauth2 web client id of this site
|
43
43
|
# @param [String] service_account_email Google service account email
|
44
44
|
# @param [String] service_account_key Google service account private p12 key
|
45
|
-
# @param [String] widget_url url to host the Gitkit widget
|
45
|
+
# @param [String] widget_url full url to host the Gitkit widget
|
46
46
|
# @param [String] server_api_key server-side Google API key
|
47
47
|
def initialize(client_id, service_account_email, service_account_key,
|
48
48
|
widget_url, server_api_key = nil)
|
@@ -70,7 +70,7 @@ module GitkitLib
|
|
70
70
|
[key, OpenSSL::X509::Certificate.new(cert)]}]
|
71
71
|
end
|
72
72
|
@certificates[key_id].public_key }
|
73
|
-
parsed_token = JWT.decode(token_string, nil, true, &key_finder)
|
73
|
+
parsed_token, _ = JWT.decode(token_string, nil, true, &key_finder)
|
74
74
|
# check expiration time
|
75
75
|
if Time.new.to_i > parsed_token['exp']
|
76
76
|
return nil, 'token expired'
|
@@ -147,7 +147,6 @@ module GitkitLib
|
|
147
147
|
|
148
148
|
# Get one-time out-of-band code for ResetPassword/ChangeEmail request
|
149
149
|
#
|
150
|
-
# @param [String] full_url the full URL of incoming request
|
151
150
|
# @param [Hash{String=>String}] param dict of HTTP POST params
|
152
151
|
# @param [String] user_ip end user's IP address
|
153
152
|
# @param [String] gitkit_token the gitkit token if user logged in
|
@@ -158,11 +157,11 @@ module GitkitLib
|
|
158
157
|
# action: OobAction
|
159
158
|
# response_body: the http body to be returned
|
160
159
|
# }
|
161
|
-
def get_oob_result(
|
160
|
+
def get_oob_result(param, user_ip, gitkit_token=nil)
|
162
161
|
if param.has_key? 'action'
|
163
162
|
begin
|
164
163
|
if param['action'] == 'resetPassword'
|
165
|
-
oob_link = build_oob_link(
|
164
|
+
oob_link = build_oob_link(
|
166
165
|
password_reset_request(param, user_ip),
|
167
166
|
param['action'])
|
168
167
|
return password_reset_response(oob_link, param)
|
@@ -170,7 +169,7 @@ module GitkitLib
|
|
170
169
|
unless gitkit_token
|
171
170
|
return failure_msg('login is required')
|
172
171
|
end
|
173
|
-
oob_link = build_oob_link(
|
172
|
+
oob_link = build_oob_link(
|
174
173
|
change_email_request(param, user_ip, gitkit_token),
|
175
174
|
param['action'])
|
176
175
|
return email_change_response(oob_link, param)
|
@@ -202,11 +201,10 @@ module GitkitLib
|
|
202
201
|
}
|
203
202
|
end
|
204
203
|
|
205
|
-
def build_oob_link(
|
204
|
+
def build_oob_link(param, mode)
|
206
205
|
code = @rpc_helper.get_oob_code(param)
|
207
206
|
if code
|
208
|
-
oob_link = Addressable::URI.parse
|
209
|
-
oob_link.path = @widget_url
|
207
|
+
oob_link = Addressable::URI.parse @widget_url
|
210
208
|
oob_link.query_values = { 'mode' => mode, 'oobCode' => code}
|
211
209
|
return oob_link.to_s
|
212
210
|
end
|
@@ -214,7 +212,7 @@ module GitkitLib
|
|
214
212
|
end
|
215
213
|
|
216
214
|
def failure_msg(msg)
|
217
|
-
{:response_body => {'error' => msg}}
|
215
|
+
{:response_body => MultiJson.dump({'error' => msg})}
|
218
216
|
end
|
219
217
|
|
220
218
|
def email_change_response(oob_link, param)
|
@@ -223,7 +221,7 @@ module GitkitLib
|
|
223
221
|
:newEmail => param['newEmail'],
|
224
222
|
:oobLink => oob_link,
|
225
223
|
:action => :CHANGE_EMAIL,
|
226
|
-
:response_body => {'success' => true}
|
224
|
+
:response_body => MultiJson.dump({'success' => true})
|
227
225
|
}
|
228
226
|
end
|
229
227
|
|
@@ -232,7 +230,7 @@ module GitkitLib
|
|
232
230
|
:email => param['email'],
|
233
231
|
:oobLink => oob_link,
|
234
232
|
:action => :RESET_PASSWORD,
|
235
|
-
:response_body => {'success' => true}
|
233
|
+
:response_body => MultiJson.dump({'success' => true})
|
236
234
|
}
|
237
235
|
end
|
238
236
|
end
|
data/lib/rpc_helper.rb
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require 'jwt'
|
16
|
-
require '
|
16
|
+
require 'multi_json'
|
17
17
|
require 'faraday'
|
18
18
|
require 'gitkit_client'
|
19
19
|
require 'openssl'
|
@@ -137,7 +137,7 @@ module GitkitLib
|
|
137
137
|
headers = {'Content-type' => 'application/x-www-form-urlencoded'}
|
138
138
|
response = @connection.post(RpcHelper::TOKEN_ENDPOINT, post_body,
|
139
139
|
headers)
|
140
|
-
@access_token =
|
140
|
+
@access_token = MultiJson.load(response.env[:body])['access_token']
|
141
141
|
@token_issued_at = Time.new.to_i
|
142
142
|
end
|
143
143
|
@access_token
|
@@ -162,13 +162,13 @@ module GitkitLib
|
|
162
162
|
# authenticated
|
163
163
|
# @return <JSON> the Gitkit api response
|
164
164
|
def invoke_gitkit_api(method, params, need_service_account=true)
|
165
|
-
post_body =
|
165
|
+
post_body = MultiJson.dump params
|
166
166
|
headers = {'Content-type' => 'application/json'}
|
167
167
|
if need_service_account
|
168
168
|
@connection.authorization :Bearer, fetch_access_token
|
169
169
|
end
|
170
170
|
response = @connection.post(GITKIT_API_URL + method, post_body, headers)
|
171
|
-
check_gitkit_error
|
171
|
+
check_gitkit_error MultiJson.load(response.env[:body])
|
172
172
|
end
|
173
173
|
|
174
174
|
# Download the Gitkit public certs
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: identity-toolkit-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jin Liu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -77,8 +77,7 @@ files:
|
|
77
77
|
- lib/gitkit_client.rb
|
78
78
|
- lib/rpc_helper.rb
|
79
79
|
homepage: https://developers.google.com/identity-toolkit/v3
|
80
|
-
licenses:
|
81
|
-
- Apache 2.0
|
80
|
+
licenses: []
|
82
81
|
metadata: {}
|
83
82
|
post_install_message:
|
84
83
|
rdoc_options: []
|