authlete 0.5.1 → 1.0.0
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/lib/authlete.rb +24 -1
- data/lib/authlete/api.rb +298 -146
- data/lib/authlete/authentication-server.rb +1 -1
- data/lib/authlete/exception.rb +6 -3
- data/lib/authlete/model/client-extension.rb +135 -135
- data/lib/authlete/model/client-list.rb +128 -128
- data/lib/authlete/model/client.rb +468 -468
- data/lib/authlete/model/hashable.rb +1 -1
- data/lib/authlete/model/pair.rb +102 -102
- data/lib/authlete/model/property.rb +116 -0
- data/lib/authlete/model/request/authentication-callback-request.rb +90 -90
- data/lib/authlete/model/request/authorization-fail-request.rb +107 -104
- data/lib/authlete/model/request/authorization-issue-request.rb +167 -133
- data/lib/authlete/model/request/authorization-request.rb +101 -101
- data/lib/authlete/model/request/client-authorization-delete-request.rb +123 -0
- data/lib/authlete/model/request/client-authorization-get-list-request.rb +123 -0
- data/lib/authlete/model/request/client-authorization-update-request.rb +118 -0
- data/lib/authlete/model/request/client-secret-update-request.rb +121 -0
- data/lib/authlete/model/request/developer-authentication-callback-request.rb +84 -84
- data/lib/authlete/model/request/granted-scopes-request.rb +103 -0
- data/lib/authlete/model/request/introspection-request.rb +117 -39
- data/lib/authlete/model/request/revocation-request.rb +125 -0
- data/lib/authlete/model/request/standard-introspection-request.rb +102 -0
- data/lib/authlete/model/request/token-create-request.rb +250 -0
- data/lib/authlete/model/request/token-fail-request.rb +104 -101
- data/lib/authlete/model/request/token-issue-request.rb +116 -101
- data/lib/authlete/model/request/token-request.rb +127 -121
- data/lib/authlete/model/request/token-update-request.rb +165 -0
- data/lib/authlete/model/request/user-info-issue-request.rb +113 -0
- data/lib/authlete/model/request/user-info-request.rb +102 -0
- data/lib/authlete/model/response/authentication-callback-response.rb +53 -53
- data/lib/authlete/model/response/authorization-fail-response.rb +48 -48
- data/lib/authlete/model/response/authorization-issue-response.rb +85 -48
- data/lib/authlete/model/response/authorization-response.rb +177 -164
- data/lib/authlete/model/response/client-authorization-get-list-response.rb +60 -0
- data/lib/authlete/model/response/client-secret-refresh-response.rb +48 -0
- data/lib/authlete/model/response/client-secret-update-response.rb +48 -0
- data/lib/authlete/model/response/developer-authentication-callback-response.rb +55 -55
- data/lib/authlete/model/response/granted-scopes-get-response.rb +63 -0
- data/lib/authlete/model/response/introspection-response.rb +163 -132
- data/lib/authlete/model/response/revocation-response.rb +49 -0
- data/lib/authlete/model/response/service-creatable-response.rb +50 -50
- data/lib/authlete/model/response/standard-introspection-response.rb +49 -0
- data/lib/authlete/model/response/token-create-response.rb +100 -0
- data/lib/authlete/model/response/token-fail-response.rb +49 -49
- data/lib/authlete/model/response/token-issue-response.rb +138 -49
- data/lib/authlete/model/response/token-response.rb +168 -70
- data/lib/authlete/model/response/token-update-response.rb +62 -0
- data/lib/authlete/model/response/user-info-issue-response.rb +47 -0
- data/lib/authlete/model/response/user-info-response.rb +85 -0
- data/lib/authlete/model/result.rb +44 -44
- data/lib/authlete/model/scope.rb +1 -1
- data/lib/authlete/model/service-list.rb +1 -1
- data/lib/authlete/model/service-owner.rb +1 -1
- data/lib/authlete/model/service.rb +4 -2
- data/lib/authlete/model/sns-credentials.rb +1 -1
- data/lib/authlete/model/tagged-value.rb +97 -97
- data/lib/authlete/utility.rb +1 -1
- data/lib/authlete/version.rb +2 -2
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2446d2444c75c96eb2157070944d7a7ab869267e
|
4
|
+
data.tar.gz: 03848b3546c1989c6505550adbd7b18fa4cff48f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7be804d22a575c32eecd87dbcc3340cd54bbb5af896fe00ec9ad4777403afe6aa17f96454c77e016983559152ad928acc652858a2d2143efc1f33dcc06f479b0
|
7
|
+
data.tar.gz: fc19d2e5abb3f004035b68a4f77534c671c56d30bb979dac3740cfdef6962759a1ff5e30a84471e91371d6be2511c1734e3919c650eb397a978ca3a7b5fcd947
|
data/lib/authlete.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# :nodoc:
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014-
|
3
|
+
# Copyright (C) 2014-2018 Authlete, Inc.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -34,6 +34,7 @@ module Authlete
|
|
34
34
|
autoload :Hashable, 'authlete/model/hashable'
|
35
35
|
autoload :Result, 'authlete/model/result'
|
36
36
|
autoload :Pair, 'authlete/model/pair'
|
37
|
+
autoload :Property, 'authlete/model/property'
|
37
38
|
autoload :Scope, 'authlete/model/scope'
|
38
39
|
autoload :Service, 'authlete/model/service'
|
39
40
|
autoload :ServiceList, 'authlete/model/service-list'
|
@@ -46,11 +47,22 @@ module Authlete
|
|
46
47
|
autoload :AuthorizationFailRequest, 'authlete/model/request/authorization-fail-request'
|
47
48
|
autoload :AuthorizationIssueRequest, 'authlete/model/request/authorization-issue-request'
|
48
49
|
autoload :AuthorizationRequest, 'authlete/model/request/authorization-request'
|
50
|
+
autoload :ClientAuthorizationDeleteRequest, 'authlete/model/request/client-authorization-delete-request'
|
51
|
+
autoload :ClientAuthorizationGetListRequest, 'authlete/model/request/client-authorization-get-list-request'
|
52
|
+
autoload :ClientAuthorizationUpdateRequest, 'authlete/model/request/client-authorization-update-request'
|
53
|
+
autoload :ClientSecretUpdateRequest, 'authlete/model/request/client-secret-update-request'
|
49
54
|
autoload :DeveloperAuthenticationCallbackRequest, 'authlete/model/request/developer-authentication-callback-request'
|
55
|
+
autoload :GrantedScopesRequest, 'authlete/model/request/granted-scopes-request'
|
50
56
|
autoload :IntrospectionRequest, 'authlete/model/request/introspection-request'
|
57
|
+
autoload :RevocationRequest, 'authlete/model/request/revocation-request'
|
58
|
+
autoload :StandardIntrospectionRequest, 'authlete/model/request/standard-introspection-request'
|
59
|
+
autoload :TokenCreateRequest, 'authlete/model/request/token-create-request'
|
51
60
|
autoload :TokenFailRequest, 'authlete/model/request/token-fail-request'
|
52
61
|
autoload :TokenIssueRequest, 'authlete/model/request/token-issue-request'
|
53
62
|
autoload :TokenRequest, 'authlete/model/request/token-request'
|
63
|
+
autoload :TokenUpdateRequest, 'authlete/model/request/token-update-request'
|
64
|
+
autoload :UserInfoIssueRequest, 'authlete/model/request/user-info-issue-request'
|
65
|
+
autoload :UserInfoRequest, 'authlete/model/request/user-info-request'
|
54
66
|
end
|
55
67
|
|
56
68
|
module Response
|
@@ -58,12 +70,23 @@ module Authlete
|
|
58
70
|
autoload :AuthorizationFailResponse, 'authlete/model/response/authorization-fail-response'
|
59
71
|
autoload :AuthorizationIssueResponse, 'authlete/model/response/authorization-issue-response'
|
60
72
|
autoload :AuthorizationResponse, 'authlete/model/response/authorization-response'
|
73
|
+
autoload :ClientAuthorizationGetListResponse, 'authlete/model/response/client-authorization-get-list-response'
|
74
|
+
autoload :ClientSecretRefreshResponse, 'authlete/model/response/client-secret-refresh-response'
|
75
|
+
autoload :ClientSecretUpdateResponse, 'authlete/model/response/client-secret-update-response'
|
76
|
+
autoload :ClientSecretRefreshResponse, 'authlete/model/response/client-secret-refresh-response'
|
61
77
|
autoload :DeveloperAuthenticationCallbackResponse, 'authlete/model/response/developer-authentication-callback-response'
|
78
|
+
autoload :GrantedScopesGetResponse, 'authlete/model/response/granted-scopes-get-response'
|
62
79
|
autoload :IntrospectionResponse, 'authlete/model/response/introspection-response'
|
80
|
+
autoload :RevocationResponse, 'authlete/model/response/revocation-response'
|
63
81
|
autoload :ServiceCreatableResponse, 'authlete/model/response/service-creatable-response'
|
82
|
+
autoload :StandardIntrospectionResponse, 'authlete/model/response/standard-introspection-response'
|
83
|
+
autoload :TokenCreateResponse, 'authlete/model/response/token-create-response'
|
64
84
|
autoload :TokenFailResponse, 'authlete/model/response/token-fail-response'
|
65
85
|
autoload :TokenIssueResponse, 'authlete/model/response/token-issue-response'
|
66
86
|
autoload :TokenResponse, 'authlete/model/response/token-response'
|
87
|
+
autoload :TokenUpdateResponse, 'authlete/model/response/token-update-response'
|
88
|
+
autoload :UserInfoIssueResponse, 'authlete/model/response/user-info-issue-response'
|
89
|
+
autoload :UserInfoResponse, 'authlete/model/response/user-info-response'
|
67
90
|
end
|
68
91
|
end
|
69
92
|
end
|
data/lib/authlete/api.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# :nodoc:
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014-
|
3
|
+
# Copyright (C) 2014-2018 Authlete, Inc.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -91,54 +91,50 @@ module Authlete
|
|
91
91
|
begin
|
92
92
|
return RestClient::Request.new(parameters).execute
|
93
93
|
rescue => e
|
94
|
-
|
94
|
+
raise create_api_exception(e)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
def
|
98
|
+
def create_api_exception(exception)
|
99
99
|
message = exception.message
|
100
100
|
response = exception.response
|
101
101
|
|
102
|
+
# Create a base exception.
|
103
|
+
authlete_exception = Authlete::Exception.new(:message => message)
|
104
|
+
|
102
105
|
if response.nil?
|
103
|
-
#
|
104
|
-
|
106
|
+
# No response information. Then, return an exception without HTTP
|
107
|
+
# response information.
|
108
|
+
return authlete_exception
|
105
109
|
end
|
106
110
|
|
107
|
-
#
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
def raise_api_exception_with_http_response_info(message, status_code, response_body)
|
112
|
-
# Parse the response body as a json.
|
113
|
-
json = parse_response_body(response_body, message, status_code)
|
111
|
+
# Extract information from the HTTP response.
|
112
|
+
status_code = response.code
|
113
|
+
response_body = response.body
|
114
114
|
|
115
|
-
#
|
116
|
-
|
117
|
-
# Raise an error with it.
|
118
|
-
hash = json.merge!(:statusCode => status_code)
|
119
|
-
raise Authlete::Exception.new(hash)
|
120
|
-
end
|
115
|
+
# Set the status code.
|
116
|
+
authlete_exception.status_code = status_code
|
121
117
|
|
122
|
-
|
123
|
-
raise Authlete::Exception.new(
|
124
|
-
:message => message,
|
125
|
-
:statusCode => status_code
|
126
|
-
)
|
127
|
-
end
|
118
|
+
response_body_json = nil
|
128
119
|
|
129
|
-
def parse_response_body(response_body, message, status_code)
|
130
120
|
begin
|
131
|
-
|
121
|
+
# Parse the response body as a json.
|
122
|
+
response_body_json = JSON.parse(response_body.to_s, :symbolize_names => true)
|
132
123
|
rescue
|
133
|
-
# Failed to parse the response body as a json.
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
124
|
+
# Failed to parse the response body as a json. Then, return an exception
|
125
|
+
# without HTTP response information.
|
126
|
+
return authlete_exception
|
127
|
+
end
|
128
|
+
|
129
|
+
# Set the Authlete API result info if it's available.
|
130
|
+
if has_authlete_api_result?(json)
|
131
|
+
authlete_exception.result = Authlete::Model::Result.new(response_body_json)
|
138
132
|
end
|
133
|
+
|
134
|
+
authlete_exception
|
139
135
|
end
|
140
136
|
|
141
|
-
def
|
137
|
+
def has_authlete_api_result?(json)
|
142
138
|
json && json.key?(:resultCode) && json.key?(:resultMessage)
|
143
139
|
end
|
144
140
|
|
@@ -202,13 +198,96 @@ module Authlete
|
|
202
198
|
"?" + array.join("&")
|
203
199
|
end
|
204
200
|
|
201
|
+
def to_hash(object)
|
202
|
+
# Return the object if it's already a hash.
|
203
|
+
return object if object.kind_of?(Hash)
|
204
|
+
|
205
|
+
# Convert the object to a hash if possible and return it.
|
206
|
+
return object.to_hash if object.respond_to?('to_hash')
|
207
|
+
|
208
|
+
# Otherwise, raise an exception.
|
209
|
+
Authlete::Exception.new(:message => "Failed to convert the object to a hash.")
|
210
|
+
end
|
211
|
+
|
205
212
|
public
|
206
213
|
|
214
|
+
# Call Authlete's /api/auth/authorization API.
|
215
|
+
#
|
216
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::AuthorizationRequest.
|
217
|
+
#
|
218
|
+
# On success, an instance of Authlete::Model::Response::AuthorizationResponse is returned.
|
219
|
+
# On error, Authlete::Exception is raised.
|
220
|
+
def authorization(request)
|
221
|
+
hash = call_api_json_service("/api/auth/authorization", to_hash(request))
|
222
|
+
|
223
|
+
Authlete::Model::Response::AuthorizationResponse.new(hash)
|
224
|
+
end
|
225
|
+
|
226
|
+
# Call Authlete's /api/auth/authorization/issue API.
|
227
|
+
#
|
228
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::AuthorizationIssueRequest.
|
229
|
+
#
|
230
|
+
# On success, an instance of Authlete::Model::Response::AuthorizationIssueResponse is returned.
|
231
|
+
# On error, Authlete::Exception is raised.
|
232
|
+
def authorization_issue(request)
|
233
|
+
hash = call_api_json_service("/api/auth/authorization/issue", to_hash(request))
|
234
|
+
|
235
|
+
Authlete::Model::Response::AuthorizationIssueResponse.new(hash)
|
236
|
+
end
|
237
|
+
|
238
|
+
# Call Authlete's /api/auth/authorization/fail API.
|
239
|
+
#
|
240
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::AuthorizationFailRequest.
|
241
|
+
#
|
242
|
+
# On success, an instance of Authlete::Model::Response::AuthorizationFailResponse is returned.
|
243
|
+
# On error, Authlete::Exception is raised.
|
244
|
+
def authorization_fail(request)
|
245
|
+
hash = call_api_json_service("/api/auth/authorization/fail", to_hash(request))
|
246
|
+
|
247
|
+
Authlete::Model::Response::AuthorizationFailResponse.new(hash)
|
248
|
+
end
|
249
|
+
|
250
|
+
# Call Authlete's /api/auth/token API.
|
251
|
+
#
|
252
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::TokenRequest.
|
253
|
+
#
|
254
|
+
# On success, an instance of Authlete::Model::Response::TokenResponse is returned.
|
255
|
+
# On error, Authlete::Exception is raised.
|
256
|
+
def token(request)
|
257
|
+
hash = call_api_json_service("/api/auth/token", to_hash(request))
|
258
|
+
|
259
|
+
Authlete::Model::Response::TokenResponse.new(hash)
|
260
|
+
end
|
261
|
+
|
262
|
+
# Call Authlete's /api/auth/token/issue API.
|
263
|
+
#
|
264
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::TokenIssueRequest.
|
265
|
+
#
|
266
|
+
# On success, an instance of Authlete::Model::Response::TokenIssueResponse is returned.
|
267
|
+
# On error, Authlete::Exception is raised.
|
268
|
+
def token_issue(request)
|
269
|
+
hash = call_api_json_service("/api/auth/token/issue", to_hash(request))
|
270
|
+
|
271
|
+
Authlete::Model::Response::TokenIssueResponse.new(hash)
|
272
|
+
end
|
273
|
+
|
274
|
+
# Call Authlete's /api/auth/token/fail API.
|
275
|
+
#
|
276
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::TokenFailRequest.
|
277
|
+
#
|
278
|
+
# On success, an instance of Authlete::Model::Response::TokenFailResponse is returned.
|
279
|
+
# On error, Authlete::Exception is raised.
|
280
|
+
def token_fail(request)
|
281
|
+
hash = call_api_json_service("/api/auth/token/fail", to_hash(request))
|
282
|
+
|
283
|
+
Authlete::Model::Response::TokenFailResponse.new(hash)
|
284
|
+
end
|
285
|
+
|
207
286
|
# Call Authlete's /api/service/creatable API.
|
208
287
|
#
|
209
288
|
# On success, an instance of Authlete::Model::Response::ServiceCreatableResponse is returned.
|
210
289
|
# On error, Authlete::Exception is raised.
|
211
|
-
def service_creatable
|
290
|
+
def service_creatable
|
212
291
|
hash = call_api_service_owner(:get, "/api/service/creatable", nil, nil)
|
213
292
|
|
214
293
|
Authlete::Model::Response::ServiceCreatableResponse.new(hash)
|
@@ -224,13 +303,7 @@ module Authlete
|
|
224
303
|
# On success, an instance of Authlete::Model::ServiceList is returned.
|
225
304
|
# On error, Authlete::Exception is raised.
|
226
305
|
def service_create(service)
|
227
|
-
|
228
|
-
if service.respond_to?('to_hash')
|
229
|
-
service = service.to_hash
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
hash = call_api_json_service_owner("/api/service/create", service)
|
306
|
+
hash = call_api_json_service_owner("/api/service/create", to_hash(service))
|
234
307
|
|
235
308
|
Authlete::Model::Service.new(hash)
|
236
309
|
end
|
@@ -282,13 +355,7 @@ module Authlete
|
|
282
355
|
# On success, an instance of Authlete::Model::Service is returned.
|
283
356
|
# On error, Authlete::Exception is raised.
|
284
357
|
def service_update(api_key, service)
|
285
|
-
|
286
|
-
if service.respond_to?('to_hash')
|
287
|
-
service = service.to_hash
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
hash = call_api_json_service_owner("/api/service/update/#{api_key}", service)
|
358
|
+
hash = call_api_json_service_owner("/api/service/update/#{api_key}", to_hash(service))
|
292
359
|
|
293
360
|
Authlete::Model::Service.new(hash)
|
294
361
|
end
|
@@ -313,30 +380,28 @@ module Authlete
|
|
313
380
|
# On success, an instance of Authlete::Model::ClientList is returned.
|
314
381
|
# On error, Authlete::Exception is raised.
|
315
382
|
def client_create(client)
|
316
|
-
|
317
|
-
if client.respond_to?('to_hash')
|
318
|
-
client = client.to_hash
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
hash = call_api_json_service("/api/client/create", client)
|
383
|
+
hash = call_api_json_service("/api/client/create", to_hash(client))
|
323
384
|
|
324
385
|
Authlete::Model::Client.new(hash)
|
325
386
|
end
|
326
387
|
|
327
388
|
# Call Authlete's /api/client/delete/{clientId} API.
|
328
389
|
#
|
390
|
+
# <tt>client_id</tt> is the client ID of a client.
|
391
|
+
#
|
329
392
|
# On error, Authlete::Exception is raised.
|
330
|
-
def client_delete(
|
331
|
-
call_api_service(:delete, "/api/client/delete/#{
|
393
|
+
def client_delete(client_id)
|
394
|
+
call_api_service(:delete, "/api/client/delete/#{client_id}", nil, nil)
|
332
395
|
end
|
333
396
|
|
334
397
|
# Call Authlete's /api/client/get/{clientId} API.
|
335
398
|
#
|
336
|
-
#
|
399
|
+
# <tt>client_id</tt> is the client ID of a client.
|
400
|
+
|
401
|
+
# On success, an instance of Authlete::Model::Client is returned.
|
337
402
|
# On error, Authlete::Exception is raised.
|
338
|
-
def client_get(
|
339
|
-
hash = call_api_service(:get, "/api/client/get/#{
|
403
|
+
def client_get(client_id)
|
404
|
+
hash = call_api_service(:get, "/api/client/get/#{client_id}", nil, nil)
|
340
405
|
|
341
406
|
Authlete::Model::Client.new(hash)
|
342
407
|
end
|
@@ -365,139 +430,219 @@ module Authlete
|
|
365
430
|
# On success, an instance of Authlete::Model::Client is returned.
|
366
431
|
# On error, Authlete::Exception is raised.
|
367
432
|
def client_update(client)
|
368
|
-
|
369
|
-
if client.respond_to?('to_hash')
|
370
|
-
client = client.to_hash
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
hash = call_api_json_service("/api/client/update/#{client[:clientId]}", client)
|
433
|
+
hash = call_api_json_service("/api/client/update/#{client[:clientId]}", to_hash(client))
|
375
434
|
|
376
435
|
Authlete::Model::Client.new(hash)
|
377
436
|
end
|
378
437
|
|
379
|
-
# Call Authlete's /api/
|
438
|
+
# Call Authlete's /api/client/secret/refresh/{clientIdentifier} API.
|
380
439
|
#
|
381
|
-
#
|
440
|
+
# <tt>clientIdentifier</tt> is the client ID or the client ID alias of a client.
|
441
|
+
#
|
442
|
+
# On success, an instance of Authlete::Model::Response::ClientSecretRefreshResponse is returned.
|
382
443
|
# On error, Authlete::Exception is raised.
|
383
|
-
def
|
384
|
-
|
385
|
-
if request.respond_to?('to_hash')
|
386
|
-
request = request.to_hash
|
387
|
-
end
|
388
|
-
end
|
444
|
+
def refresh_client_secret(client_identifier)
|
445
|
+
hash = call_api_service(:get, "/api/client/secret/refresh/#{client_identifier}", nil, nil)
|
389
446
|
|
390
|
-
hash
|
447
|
+
Authlete::Model::ClientSecretRefreshResponse.new(hash)
|
448
|
+
end
|
391
449
|
|
392
|
-
|
450
|
+
# Call Authlete's /api/client/secret/update/{clientIdentifier} API.
|
451
|
+
#
|
452
|
+
# <tt>client_identifier</tt> is the client ID or the client ID alias of a client.
|
453
|
+
# <tt>client_secret</tt> is the client secret of a client.
|
454
|
+
#
|
455
|
+
# On success, an instance of Authlete::Model::Response::ClientSecretUpdateResponse is returned.
|
456
|
+
# On error, Authlete::Exception is raised.
|
457
|
+
def update_client_secret(client_identifier, client_secret)
|
458
|
+
request = Authlete::Model::ClientSecretUpdateRequest.new(:client_secret => client_secret)
|
459
|
+
|
460
|
+
hash = call_api_json_service("/api/client/secret/update/#{client_identifier}", request.to_hash)
|
461
|
+
|
462
|
+
Authlete::Model::ClientSecretUpdateResponse.new(hash)
|
393
463
|
end
|
394
464
|
|
395
|
-
# Call Authlete's /api/
|
465
|
+
# Call Authlete's /api/client/authorization/get/list API.
|
396
466
|
#
|
397
|
-
#
|
467
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::ClientSecretUpdateRequest.
|
468
|
+
#
|
469
|
+
# On success, an instance of Authlete::Model::Response::ClientAuthorizationListResponse is returned.
|
398
470
|
# On error, Authlete::Exception is raised.
|
399
|
-
def
|
400
|
-
|
401
|
-
if request.respond_to?('to_hash')
|
402
|
-
request = request.to_hash
|
403
|
-
end
|
404
|
-
end
|
471
|
+
def get_client_authorization_list(request)
|
472
|
+
hash = call_api_json_service("/api/client/authorization/get/list", to_hash(request))
|
405
473
|
|
406
|
-
hash
|
474
|
+
Authlete::Model::ClientAuthorizationListResponse.new(hash)
|
475
|
+
end
|
407
476
|
|
408
|
-
|
477
|
+
# Call Authlete's /api/client/authorization/update API.
|
478
|
+
#
|
479
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::ClientSecretUpdateRequest.
|
480
|
+
#
|
481
|
+
# On error, Authlete::Exception is raised.
|
482
|
+
def update_client_authorization(client_id, request)
|
483
|
+
call_api_json_service("/api/client/authorization/update/#{client_id}", to_hash(request))
|
409
484
|
end
|
410
485
|
|
411
|
-
# Call Authlete's /api/
|
486
|
+
# Call Authlete's /api/client/authorization/delete/{clientId} API.
|
487
|
+
#
|
488
|
+
# <tt>client_id</tt> is the client ID of a client.
|
489
|
+
# <tt>subject</tt> is the unique ID of an end user.
|
412
490
|
#
|
413
|
-
# On success, an instance of Authlete::Model::Response::AuthorizationFailResponse is returned.
|
414
491
|
# On error, Authlete::Exception is raised.
|
415
|
-
def
|
416
|
-
|
417
|
-
if request.respond_to?('to_hash')
|
418
|
-
request = request.to_hash
|
419
|
-
end
|
420
|
-
end
|
492
|
+
def delete_client_authorization(client_id, subject)
|
493
|
+
request = Authlete::Model::ClientAuthorizationDeleteRequest.new(:subject => subject)
|
421
494
|
|
422
|
-
|
495
|
+
call_api_json_service("/api/client/authorization/delete/#{client_id}", request.to_hash)
|
496
|
+
end
|
423
497
|
|
424
|
-
|
498
|
+
# Call Authlete's /api/auth/introspection API.
|
499
|
+
#
|
500
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::IntrospectionRequest.
|
501
|
+
#
|
502
|
+
# On success, an instance of Authlete::Model::Response::IntrospectionResponse is returned.
|
503
|
+
# On error, Authlete::Exception is raised.
|
504
|
+
def introspection(request)
|
505
|
+
hash = call_api_json_service('/api/auth/introspection', to_hash(request))
|
506
|
+
|
507
|
+
Authlete::Model::Response::IntrospectionResponse.new(hash)
|
425
508
|
end
|
426
509
|
|
427
|
-
# Call Authlete's /api/auth/
|
510
|
+
# Call Authlete's /api/auth/introspection/standard API.
|
428
511
|
#
|
429
|
-
#
|
512
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::StandardIntrospectionRequest.
|
513
|
+
#
|
514
|
+
# On success, an instance of Authlete::Model::Response::StandardIntrospectionResponse is returned.
|
430
515
|
# On error, Authlete::Exception is raised.
|
431
|
-
def
|
432
|
-
|
433
|
-
if request.respond_to?('to_hash')
|
434
|
-
request = request.to_hash
|
435
|
-
end
|
436
|
-
end
|
516
|
+
def standard_introspection(request)
|
517
|
+
hash = call_api_json_service('/api/auth/introspection/standard', to_hash(request))
|
437
518
|
|
438
|
-
hash
|
519
|
+
Authlete::Model::Response::StandardIntrospectionResopnse.new(hash)
|
520
|
+
end
|
439
521
|
|
440
|
-
|
522
|
+
# Call Authlete's /api/auth/revocation API.
|
523
|
+
#
|
524
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::RevocationRequest.
|
525
|
+
#
|
526
|
+
# On success, an instance of Authlete::Model::Response::RevocationResponse is returned.
|
527
|
+
# On error, Authlete::Exception is raised.
|
528
|
+
def revocation(request)
|
529
|
+
hash = call_api_json_service("/api/auth/revocation", to_hash(request))
|
530
|
+
|
531
|
+
Authlete::Model::RevocationResponse.new(hash)
|
441
532
|
end
|
442
533
|
|
443
|
-
# Call Authlete's /api/auth/
|
534
|
+
# Call Authlete's /api/auth/userinfo API.
|
444
535
|
#
|
445
|
-
#
|
536
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::UserInfoRequest.
|
537
|
+
#
|
538
|
+
# On success, an instance of Authlete::Model::Response::UserInfoResponse is returned.
|
446
539
|
# On error, Authlete::Exception is raised.
|
447
|
-
def
|
448
|
-
|
449
|
-
if request.respond_to?('to_hash')
|
450
|
-
request = request.to_hash
|
451
|
-
end
|
452
|
-
end
|
540
|
+
def user_info(request)
|
541
|
+
hash = call_api_json_service("/api/auth/userinfo", to_hash(request))
|
453
542
|
|
454
|
-
hash
|
543
|
+
Authlete::Model::UserInfoResponse.new(hash)
|
544
|
+
end
|
455
545
|
|
456
|
-
|
546
|
+
# Call Authlete's /api/auth/userinfo/issue API.
|
547
|
+
#
|
548
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::UserInfoIssueRequest.
|
549
|
+
#
|
550
|
+
# On success, an instance of Authlete::Model::Response::UserInfoIssueResponse is returned.
|
551
|
+
# On error, Authlete::Exception is raised.
|
552
|
+
def user_info_issue(request)
|
553
|
+
hash = call_api_json_service("/api/auth/userinfo/issue", to_hash(request))
|
554
|
+
|
555
|
+
Authlete::Model::UserInfoIssueResponse.new(hash)
|
457
556
|
end
|
458
557
|
|
459
|
-
# Call Authlete's /api/
|
558
|
+
# Call Authlete's /api/service/jwks/get API.
|
460
559
|
#
|
461
|
-
#
|
560
|
+
# <tt>params</tt> is an optional hash which contains query parameters
|
561
|
+
# for /api/service/jwks/get API. The hash can contain the following parameters.
|
562
|
+
#
|
563
|
+
# <tt>:includePrivateKeys</tt>
|
564
|
+
# This boolean value indicates whether the response should include the
|
565
|
+
# private keys associated with the service or not. If "true", the private
|
566
|
+
# keys are included in the response. The default value is "false".
|
567
|
+
#
|
568
|
+
# <tt>:pretty</tt>
|
569
|
+
# This boolean value indicates whether the JSON in the response should
|
570
|
+
# be formatted or not. If true, the JSON in the response is pretty-formatted.
|
571
|
+
# The default value is false.
|
572
|
+
#
|
573
|
+
# On success, a JWK Set for a service is returned.
|
462
574
|
# On error, Authlete::Exception is raised.
|
463
|
-
def
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
575
|
+
def get_service_jwks(params = nil)
|
576
|
+
call_api_service(:get, "/api/service/jwks/get#{to_query(params)}", nil, nil)
|
577
|
+
end
|
578
|
+
|
579
|
+
# Call Authlete's /api/service/configuration API.
|
580
|
+
#
|
581
|
+
# <tt>params</tt> is an optional hash which contains query parameters
|
582
|
+
# for /api/service/configuration API. The hash can contain the following
|
583
|
+
# parameter.
|
584
|
+
#
|
585
|
+
# <tt>:includePrivateKeys</tt>
|
586
|
+
# This boolean value indicates whether the response should include the
|
587
|
+
# private keys associated with the service or not. If "true", the private
|
588
|
+
# keys are included in the response. The default value is "false".
|
589
|
+
#
|
590
|
+
# On success, configuration information of a service is returned.
|
591
|
+
# On error, Authlete::Exception is raised.
|
592
|
+
def get_service_configuration(params = nil)
|
593
|
+
call_api_service(:get, "/api/service/configuration#{to_query(params)}", nil, nil)
|
594
|
+
end
|
469
595
|
|
470
|
-
|
596
|
+
# Call Authlete's /api/auth/token/create API.
|
597
|
+
#
|
598
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::TokenCreateRequest.
|
599
|
+
#
|
600
|
+
# On success, an instance of Authlete::Model::Response::TokenCreateResponse is returned.
|
601
|
+
# On error, Authlete::Exception is raised.
|
602
|
+
def token_create(request)
|
603
|
+
hash = call_api_json_service("/api/auth/token/create", to_hash(request))
|
471
604
|
|
472
|
-
Authlete::Model::
|
605
|
+
Authlete::Model::TokenCreateResponse.new(hash)
|
473
606
|
end
|
474
607
|
|
475
|
-
# Call Authlete's /api/auth/
|
608
|
+
# Call Authlete's /api/auth/token/update API.
|
476
609
|
#
|
477
|
-
# <tt>
|
478
|
-
# This is a must parameter. In a typical case, a client application uses
|
479
|
-
# one of the means listed in {RFC 6750}[https://tools.ietf.org/html/rfc6750]
|
480
|
-
# to present an access token to a {protected resource endpoint}
|
481
|
-
# [https://tools.ietf.org/html/rfc6749#section-7].
|
610
|
+
# <tt>request</tt> is an instance of Authlete::Model::Request::TokenUpdateRequest.
|
482
611
|
#
|
483
|
-
#
|
484
|
-
#
|
485
|
-
|
612
|
+
# On success, an instance of Authlete::Model::Response::TokenUpdateResponse is returned.
|
613
|
+
# On error, Authlete::Exception is raised.
|
614
|
+
def token_update(request)
|
615
|
+
hash = call_api_json_service("/api/auth/token/update", to_hash(request))
|
616
|
+
|
617
|
+
Authlete::Model::TokenUpdateResponse.new(hash)
|
618
|
+
end
|
619
|
+
|
620
|
+
# Call Authlete's /api/client/granted_scopes/get/{clientId} API.
|
486
621
|
#
|
487
|
-
# <tt>
|
488
|
-
#
|
489
|
-
# subject, Authlete prepares the content of the error response.
|
622
|
+
# <tt>client_id</tt> is the client ID of a client.
|
623
|
+
# <tt>subject</tt> is the unique ID of an end user.
|
490
624
|
#
|
491
|
-
# On success,
|
492
|
-
#
|
493
|
-
|
494
|
-
|
495
|
-
hash = call_api_json_service('/api/auth/introspection',
|
496
|
-
:token => token, :scopes => scopes, :subject => subject)
|
625
|
+
# On success, an instance of Authlete::Model::Response::GrantedScopesGetResponse is returned.
|
626
|
+
# On error, Authlete::Exception is raised.
|
627
|
+
def get_granted_scopes(client_id, subject)
|
628
|
+
request = Authlete::Model::GrantedScopesRequest.new(:subject => subject)
|
497
629
|
|
498
|
-
|
630
|
+
hash = call_api_json_service("/api/client/granted_scopes/get/#{client_id}", request.to_hash)
|
631
|
+
|
632
|
+
Authlete::Model::Response::GrantedScopesGetResponse.new(hash)
|
499
633
|
end
|
500
634
|
|
635
|
+
# Call Authlete's /api/client/granted_scopes/delete/{clientId} API.
|
636
|
+
#
|
637
|
+
# <tt>client_id</tt> is the client ID of a client.
|
638
|
+
# <tt>subject</tt> is the unique ID of an end user.
|
639
|
+
#
|
640
|
+
# On error, Authlete::Exception is raised.
|
641
|
+
def delete_granted_scopes(client_id, subject)
|
642
|
+
request = Authlete::Model::GrantedScopesRequest.new(:subject => subject)
|
643
|
+
|
644
|
+
call_api_json_service("/api/client/granted_scopes/delete/#{client_id}", request.to_hash)
|
645
|
+
end
|
501
646
|
|
502
647
|
# Ensure that the request contains a valid access token.
|
503
648
|
#
|
@@ -534,9 +679,16 @@ module Authlete
|
|
534
679
|
)
|
535
680
|
end
|
536
681
|
|
682
|
+
# Create a request for Authlete's /api/auth/introspection API.
|
683
|
+
request = Authlete::Model::Request::IntrospectionRequest.new(
|
684
|
+
:token => access_token,
|
685
|
+
:scopes => scopes,
|
686
|
+
:subject => subject
|
687
|
+
)
|
688
|
+
|
537
689
|
begin
|
538
690
|
# Call Authlete's /api/auth/introspection API to introspect the access token.
|
539
|
-
result = introspection(
|
691
|
+
result = introspection(request)
|
540
692
|
rescue => e
|
541
693
|
# Error message.
|
542
694
|
message = build_error_message('/api/auth/introspection', e)
|