authlete 1.0.22 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -1
  3. data/Makefile +40 -0
  4. data/Rakefile +5 -0
  5. data/authlete.gemspec +2 -2
  6. data/lib/authlete.rb +28 -9
  7. data/lib/authlete/api.rb +153 -322
  8. data/lib/authlete/authentication-server.rb +2 -2
  9. data/lib/authlete/exception.rb +14 -15
  10. data/lib/authlete/model/base.rb +30 -0
  11. data/lib/authlete/model/client-extension.rb +17 -119
  12. data/lib/authlete/model/client.rb +205 -342
  13. data/lib/authlete/model/hashable.rb +13 -33
  14. data/lib/authlete/model/named-uri.rb +13 -74
  15. data/lib/authlete/model/pair.rb +13 -74
  16. data/lib/authlete/model/param-initializer.rb +45 -0
  17. data/lib/authlete/model/property.rb +15 -85
  18. data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
  19. data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
  20. data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
  21. data/lib/authlete/model/request/authorization-request.rb +8 -73
  22. data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
  23. data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
  24. data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
  25. data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
  26. data/lib/authlete/model/request/base.rb +26 -0
  27. data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
  28. data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
  29. data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
  30. data/lib/authlete/model/request/client-registration-request.rb +49 -0
  31. data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
  32. data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
  33. data/lib/authlete/model/request/device-authorization-request.rb +63 -0
  34. data/lib/authlete/model/request/device-complete-request.rb +99 -0
  35. data/lib/authlete/model/request/device-verification-request.rb +40 -0
  36. data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
  37. data/lib/authlete/model/request/introspection-request.rb +24 -83
  38. data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
  39. data/lib/authlete/model/request/revocation-request.rb +14 -88
  40. data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
  41. data/lib/authlete/model/request/token-create-request.rb +52 -183
  42. data/lib/authlete/model/request/token-fail-request.rb +12 -74
  43. data/lib/authlete/model/request/token-issue-request.rb +22 -80
  44. data/lib/authlete/model/request/token-request.rb +44 -81
  45. data/lib/authlete/model/request/token-update-request.rb +35 -121
  46. data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
  47. data/lib/authlete/model/request/user-info-request.rb +25 -70
  48. data/lib/authlete/model/response/access-token.rb +96 -0
  49. data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
  50. data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
  51. data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
  52. data/lib/authlete/model/response/authorization-response.rb +97 -123
  53. data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
  54. data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
  55. data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
  56. data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
  57. data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
  58. data/lib/authlete/model/response/client-list-response.rb +58 -0
  59. data/lib/authlete/model/response/client-registration-response.rb +50 -0
  60. data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
  61. data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
  62. data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
  63. data/lib/authlete/model/response/device-authorization-response.rb +134 -0
  64. data/lib/authlete/model/response/device-complete-response.rb +39 -0
  65. data/lib/authlete/model/response/device-verification-response.rb +96 -0
  66. data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
  67. data/lib/authlete/model/response/introspection-response.rb +64 -58
  68. data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
  69. data/lib/authlete/model/response/revocation-response.rb +12 -15
  70. data/lib/authlete/model/response/service-list-response.rb +54 -0
  71. data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
  72. data/lib/authlete/model/response/token-create-response.rb +50 -55
  73. data/lib/authlete/model/response/token-fail-response.rb +14 -17
  74. data/lib/authlete/model/response/token-issue-response.rb +49 -62
  75. data/lib/authlete/model/response/token-list-response.rb +64 -0
  76. data/lib/authlete/model/response/token-response.rb +59 -79
  77. data/lib/authlete/model/response/token-update-response.rb +28 -23
  78. data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
  79. data/lib/authlete/model/response/user-info-response.rb +48 -42
  80. data/lib/authlete/model/result.rb +14 -13
  81. data/lib/authlete/model/scope.rb +29 -119
  82. data/lib/authlete/model/service-owner.rb +32 -116
  83. data/lib/authlete/model/service.rb +491 -666
  84. data/lib/authlete/model/sns-credentials.rb +18 -91
  85. data/lib/authlete/model/tagged-value.rb +14 -69
  86. data/lib/authlete/utility.rb +3 -32
  87. data/lib/authlete/version.rb +3 -3
  88. data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
  89. data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
  90. data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
  91. data/test/authlete/model/request/test_authorization-request.rb +57 -0
  92. data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
  93. data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
  94. data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
  95. data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
  96. data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
  97. data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
  98. data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
  99. data/test/authlete/model/request/test_client-registration-request.rb +68 -0
  100. data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
  101. data/test/authlete/model/request/test_device-complete-request.rb +102 -0
  102. data/test/authlete/model/request/test_device-verification-request.rb +57 -0
  103. data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
  104. data/test/authlete/model/request/test_introspection-request.rb +79 -0
  105. data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
  106. data/test/authlete/model/request/test_revocation-request.rb +67 -0
  107. data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
  108. data/test/authlete/model/request/test_token-create-request.rb +110 -0
  109. data/test/authlete/model/request/test_token-fail-request.rb +63 -0
  110. data/test/authlete/model/request/test_token-issue-request.rb +70 -0
  111. data/test/authlete/model/request/test_token-request.rb +94 -0
  112. data/test/authlete/model/request/test_token-update-request.rb +82 -0
  113. data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
  114. data/test/authlete/model/request/test_user-info-request.rb +75 -0
  115. data/test/authlete/model/response/test_access-token.rb +101 -0
  116. data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
  117. data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
  118. data/test/authlete/model/response/test_authorization-response.rb +145 -0
  119. data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
  120. data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
  121. data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
  122. data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
  123. data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
  124. data/test/authlete/model/response/test_client-list-response.rb +79 -0
  125. data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
  126. data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
  127. data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
  128. data/test/authlete/model/response/test_device-complete-response.rb +64 -0
  129. data/test/authlete/model/response/test_device-verification-response.rb +112 -0
  130. data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
  131. data/test/authlete/model/response/test_introspection-response.rb +127 -0
  132. data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
  133. data/test/authlete/model/response/test_revocation-response.rb +68 -0
  134. data/test/authlete/model/response/test_service-list-response.rb +72 -0
  135. data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
  136. data/test/authlete/model/response/test_token-create-response.rb +107 -0
  137. data/test/authlete/model/response/test_token-fail-response.rb +68 -0
  138. data/test/authlete/model/response/test_token-issue-response.rb +127 -0
  139. data/test/authlete/model/response/test_token-list-response.rb +84 -0
  140. data/test/authlete/model/response/test_token-response.rb +147 -0
  141. data/test/authlete/model/response/test_token-update-response.rb +87 -0
  142. data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
  143. data/test/authlete/model/response/test_user-info-response.rb +107 -0
  144. data/test/authlete/model/test_client-extension.rb +93 -0
  145. data/test/authlete/model/test_client.rb +469 -0
  146. data/test/authlete/model/test_named-uri.rb +83 -0
  147. data/test/authlete/model/test_pair.rb +83 -0
  148. data/test/authlete/model/test_property.rb +88 -0
  149. data/test/authlete/model/test_result.rb +68 -0
  150. data/test/authlete/model/test_scope.rb +104 -0
  151. data/test/authlete/model/test_service-owner.rb +80 -0
  152. data/test/authlete/model/test_service.rb +630 -0
  153. data/test/authlete/model/test_sns-credentials.rb +88 -0
  154. data/test/authlete/model/test_tagged-value.rb +83 -0
  155. data/test/authlete/test_exception.rb +70 -0
  156. metadata +173 -12
  157. data/lib/authlete/model/client-list.rb +0 -129
  158. data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
  159. data/lib/authlete/model/response/service-creatable-response.rb +0 -51
  160. data/lib/authlete/model/service-list.rb +0 -128
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 76874c7e1a1d4c0ce39569f657df73d1d445df1907bfa08602eb75fae353ce79
4
- data.tar.gz: 7ce55dd3873f5b4a79f2df58ce84da52d0c45889701820e5a711fd1d12c496ac
2
+ SHA1:
3
+ metadata.gz: e0b0558488bf3a4a4265e05d2d1d015de18a1476
4
+ data.tar.gz: c6493cf2652ebaf784c3251940fc6ec8ed5812f5
5
5
  SHA512:
6
- metadata.gz: 62a1f340f9c25fb0a052ef5211dd4e0809f68a26b9a3e5e4e204dab8cbf5c22f8e5f1733ee063330b0d3d7cdbf0b92189ec3c7b5a90510de7d572f474c3f3c74
7
- data.tar.gz: c44961fd3bead0938e2f7db4f1e980495ec4f826974d218dcb90b57870dd5348a043d9b9f2b2ca066da19918b677e435899a0166820d821c785184a4e72061f0
6
+ metadata.gz: 2c7efb96bedc54703dffda85a82ac39898a11c99d36adf0d4c62e008bd8d5f2c0c5bedcba65273c9aef9aafb524ca39d9d26d759c1e20043053fdad63327bd5c
7
+ data.tar.gz: a475cbdfd0f88572cd7b26d27c0728f2fc9e757930318151da7523974b3eb08959975b06857b209e64c29c909e443ca15452c731dc1d3639f175a8bc328695e0
data/.gitignore CHANGED
@@ -12,4 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
- .idea/
15
+ .idea/
16
+ .DS_Store
data/Makefile ADDED
@@ -0,0 +1,40 @@
1
+ #
2
+ # Copyright (C) 2020 Authlete, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing,
11
+ # software distributed under the License is distributed on an
12
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13
+ # either express or implied. See the License for the specific
14
+ # language governing permissions and limitations under the
15
+ # License.
16
+
17
+
18
+ #==================================================
19
+ # VARIABLES
20
+ #==================================================
21
+ RAKE = rake
22
+
23
+
24
+ #==================================================
25
+ # TARGETS
26
+ #==================================================
27
+ .PHONY: _default help test
28
+
29
+
30
+ _default: help
31
+
32
+
33
+ help:
34
+ @printf '%s\n' \
35
+ "help - shows this help text." \
36
+ "test - runs tests."
37
+
38
+ test:
39
+ $(RAKE) test
40
+
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
2
3
 
4
+ # Add "test" task
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = 'test/**/test_*.rb'
7
+ end
data/authlete.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'authlete/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "authlete"
8
8
  spec.version = Authlete::VERSION
9
- spec.authors = ["Takahiko Kawasaki"]
10
- spec.email = ["taka@authlete.com"]
9
+ spec.authors = ["Takahiko Kawasaki", "Hideki Ikeda"]
10
+ spec.email = ["admin@authlete.com"]
11
11
  spec.summary = "A library for Authlete Web APIs"
12
12
  spec.description = "A library for Authlete Web APIs. See https://docs.authlete.com/ for details."
13
13
  spec.homepage = "https://www.authlete.com/"
data/lib/authlete.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2018 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 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.
@@ -18,18 +18,16 @@
18
18
  require 'authlete/version'
19
19
 
20
20
 
21
- # == Authlete Module
22
- #
23
- # A library for Authlete Web APIs.
24
21
  module Authlete
25
22
  autoload :AuthenticationServer, 'authlete/authentication-server'
26
23
  autoload :Api, 'authlete/api'
27
24
  autoload :Exception, 'authlete/exception'
25
+ autoload :ParamInitializer, 'authlete/model/param-initializer'
28
26
  autoload :Utility, 'authlete/utility'
29
27
 
30
28
  module Model
29
+ autoload :Base, 'authlete/model/base'
31
30
  autoload :Client, 'authlete/model/client'
32
- autoload :ClientList, 'authlete/model/client-list'
33
31
  autoload :ClientExtension, 'authlete/model/client-extension'
34
32
  autoload :Hashable, 'authlete/model/hashable'
35
33
  autoload :Result, 'authlete/model/result'
@@ -37,7 +35,6 @@ module Authlete
37
35
  autoload :Property, 'authlete/model/property'
38
36
  autoload :Scope, 'authlete/model/scope'
39
37
  autoload :Service, 'authlete/model/service'
40
- autoload :ServiceList, 'authlete/model/service-list'
41
38
  autoload :ServiceOwner, 'authlete/model/service-owner'
42
39
  autoload :SnsCredentials, 'authlete/model/sns-credentials'
43
40
  autoload :TaggedValue, 'authlete/model/tagged-value'
@@ -48,13 +45,23 @@ module Authlete
48
45
  autoload :AuthorizationFailRequest, 'authlete/model/request/authorization-fail-request'
49
46
  autoload :AuthorizationIssueRequest, 'authlete/model/request/authorization-issue-request'
50
47
  autoload :AuthorizationRequest, 'authlete/model/request/authorization-request'
48
+ autoload :BackchannelAuthenticationCompleteRequest, 'authlete/model/request/backchannel-authentication-complete-request'
49
+ autoload :BackchannelAuthenticationFailRequest, 'authlete/model/request/backchannel-authentication-fail-request'
50
+ autoload :BackchannelAuthenticationIssueRequest, 'authlete/model/request/backchannel-authentication-issue-request'
51
+ autoload :BackchannelAuthenticationRequest, 'authlete/model/request/backchannel-authentication-request'
52
+ autoload :Base, 'authlete/model/request/base'
51
53
  autoload :ClientAuthorizationDeleteRequest, 'authlete/model/request/client-authorization-delete-request'
52
54
  autoload :ClientAuthorizationGetListRequest, 'authlete/model/request/client-authorization-get-list-request'
53
55
  autoload :ClientAuthorizationUpdateRequest, 'authlete/model/request/client-authorization-update-request'
56
+ autoload :ClientRegistrationRequest, 'authlete/model/request/client-registration-request'
54
57
  autoload :ClientSecretUpdateRequest, 'authlete/model/request/client-secret-update-request'
55
58
  autoload :DeveloperAuthenticationCallbackRequest, 'authlete/model/request/developer-authentication-callback-request'
59
+ autoload :DeviceAuthorizationRequest, 'authlete/model/request/device-authorization-request'
60
+ autoload :DeviceCompleteRequest, 'authlete/model/request/device-complete-request'
61
+ autoload :DeviceVerificationRequest, 'authlete/model/request/device-verification-request'
56
62
  autoload :GrantedScopesRequest, 'authlete/model/request/granted-scopes-request'
57
63
  autoload :IntrospectionRequest, 'authlete/model/request/introspection-request'
64
+ autoload :PushedAuthReqRequest, 'authlete/model/request/pushed-auth-req-request'
58
65
  autoload :RevocationRequest, 'authlete/model/request/revocation-request'
59
66
  autoload :StandardIntrospectionRequest, 'authlete/model/request/standard-introspection-request'
60
67
  autoload :TokenCreateRequest, 'authlete/model/request/token-create-request'
@@ -67,27 +74,39 @@ module Authlete
67
74
  end
68
75
 
69
76
  module Response
77
+ autoload :AccessToken, 'authlete/model/response/access-token'
70
78
  autoload :AuthenticationCallbackResponse, 'authlete/model/response/authentication-callback-response'
71
79
  autoload :AuthorizationFailResponse, 'authlete/model/response/authorization-fail-response'
72
80
  autoload :AuthorizationIssueResponse, 'authlete/model/response/authorization-issue-response'
73
81
  autoload :AuthorizationResponse, 'authlete/model/response/authorization-response'
74
- autoload :ClientAuthorizationGetListResponse, 'authlete/model/response/client-authorization-get-list-response'
82
+ autoload :AuthorizedClientListResponse, 'authlete/model/response/authorized-client-list-response'
83
+ autoload :BackchannelAuthenticationCompleteResponse, 'authlete/model/response/backchannel-authentication-complete-response'
84
+ autoload :BackchannelAuthenticationFailResponse, 'authlete/model/response/backchannel-authentication-fail-response'
85
+ autoload :BackchannelAuthenticationIssueResponse, 'authlete/model/response/backchannel-authentication-issue-response'
86
+ autoload :BackchannelAuthenticationResponse, 'authlete/model/response/backchannel-authentication-response'
87
+ autoload :ClientListResponse, 'authlete/model/response/client-list-response'
88
+ autoload :ClientRegistrationResponse, 'authlete/model/response/client-registration-response'
75
89
  autoload :ClientSecretRefreshResponse, 'authlete/model/response/client-secret-refresh-response'
76
90
  autoload :ClientSecretUpdateResponse, 'authlete/model/response/client-secret-update-response'
77
91
  autoload :ClientSecretRefreshResponse, 'authlete/model/response/client-secret-refresh-response'
78
92
  autoload :DeveloperAuthenticationCallbackResponse, 'authlete/model/response/developer-authentication-callback-response'
93
+ autoload :DeviceAuthorizationResponse, 'authlete/model/response/device-authorization-response'
94
+ autoload :DeviceCompleteResponse, 'authlete/model/response/device-complete-response'
95
+ autoload :DeviceVerificationResponse, 'authlete/model/response/device-verification-response'
79
96
  autoload :GrantedScopesGetResponse, 'authlete/model/response/granted-scopes-get-response'
80
97
  autoload :IntrospectionResponse, 'authlete/model/response/introspection-response'
98
+ autoload :PushedAuthReqResponse, 'authlete/model/response/pushed-auth-req-response'
81
99
  autoload :RevocationResponse, 'authlete/model/response/revocation-response'
82
- autoload :ServiceCreatableResponse, 'authlete/model/response/service-creatable-response'
100
+ autoload :ServiceListResponse, 'authlete/model/response/service-list-response'
83
101
  autoload :StandardIntrospectionResponse, 'authlete/model/response/standard-introspection-response'
84
102
  autoload :TokenCreateResponse, 'authlete/model/response/token-create-response'
85
103
  autoload :TokenFailResponse, 'authlete/model/response/token-fail-response'
86
104
  autoload :TokenIssueResponse, 'authlete/model/response/token-issue-response'
105
+ autoload :TokenListResponse, 'authlete/model/response/token-list-response'
87
106
  autoload :TokenResponse, 'authlete/model/response/token-response'
88
107
  autoload :TokenUpdateResponse, 'authlete/model/response/token-update-response'
89
108
  autoload :UserInfoIssueResponse, 'authlete/model/response/user-info-issue-response'
90
109
  autoload :UserInfoResponse, 'authlete/model/response/user-info-response'
91
110
  end
92
111
  end
93
- end
112
+ end
data/lib/authlete/api.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2018 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 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.
@@ -21,86 +21,64 @@ require 'rest-client'
21
21
 
22
22
 
23
23
  module Authlete
24
- # == Authlete::Api Module
25
- #
26
- # A web client that accesses Authlete Web APIs.
27
- #
28
24
  class Api
29
25
  include Authlete::Utility
30
26
 
31
- # The host which provides Authlete Web APIs.
32
- # For example, <tt>https://dev-api.authlete.com</tt>
33
27
  attr_accessor :host
34
-
35
- # The API key of a service owner.
36
28
  attr_accessor :service_owner_api_key
37
-
38
- # The API secret of a service owner.
39
29
  attr_accessor :service_owner_api_secret
40
-
41
- # The API key of a service.
42
30
  attr_accessor :service_api_key
43
-
44
- # The API secret of a service.
45
31
  attr_accessor :service_api_secret
46
-
47
- # Extra HTTP headers
48
32
  attr_accessor :extra_headers
49
33
 
50
34
  private
51
35
 
52
- # The constructor which takes a hash containing configuration
53
- # parameters. Valid configuration parameter names are as follows.
54
- #
55
- # - <tt>:host</tt>
56
- # - <tt>:service_owner_api_key</tt>
57
- # - <tt>:service_owner_api_secret</tt>
58
- # - <tt>:service_api_key</tt>
59
- # - <tt>:service_api_secret</tt>
60
- #
61
36
  def initialize(config = {})
62
- @host = extract_value(config, :host)
63
- @service_owner_api_key = extract_value(config, :service_owner_api_key)
64
- @service_owner_api_secret = extract_value(config, :service_owner_api_secret)
65
- @service_api_key = extract_value(config, :service_api_key)
66
- @service_api_secret = extract_value(config, :service_api_secret)
37
+ @host = config[:host]
38
+ @service_owner_api_key = config[:service_owner_api_key]
39
+ @service_owner_api_secret = config[:service_owner_api_secret]
40
+ @service_api_key = config[:service_api_key]
41
+ @service_api_secret = config[:service_api_secret]
42
+ @extra_headers = nil
67
43
  end
68
44
 
69
45
  def call_api(method, path, content_type, payload, user, password)
70
46
  headers = {}
71
47
 
72
- headers.merge!(:content_type => content_type) unless content_type.nil?
48
+ headers.merge!(content_type: content_type) unless content_type.nil?
73
49
 
74
50
  headers.merge!(@extra_headers) unless @extra_headers.nil?
75
51
 
76
52
  response = execute(
77
- :method => method,
78
- :url => @host + path,
79
- :headers => headers,
80
- :payload => payload,
81
- :user => user,
82
- :password => password
53
+ method: method,
54
+ url: @host + path,
55
+ headers: headers,
56
+ payload: payload,
57
+ user: user,
58
+ password: password
83
59
  )
84
60
 
85
61
  body = body_as_string(response)
86
62
 
87
- body.nil? ? nil : JSON.parse(response.body.to_s, :symbolize_names => true)
63
+ body && JSON.parse(body, symbolize_names: true)
88
64
  end
89
65
 
90
66
  def execute(parameters)
91
67
  begin
92
68
  return RestClient::Request.new(parameters).execute
69
+ rescue RestClient::Exception => e
70
+ raise on_rest_client_exception(e)
93
71
  rescue => e
94
- raise create_api_exception(e)
72
+ raise on_general_exception(e)
95
73
  end
96
74
  end
97
75
 
98
- def create_api_exception(exception)
76
+ def on_rest_client_exception(exception)
99
77
  message = exception.message
100
78
  response = exception.response
101
79
 
102
80
  # Create a base exception.
103
- authlete_exception = Authlete::Exception.new(:message => message)
81
+ authlete_exception = Authlete::Exception.new(message: message)
104
82
 
105
83
  if response.nil?
106
84
  # No response information. Then, return an exception without HTTP
@@ -119,7 +97,7 @@ module Authlete
119
97
 
120
98
  begin
121
99
  # Parse the response body as a json.
122
- response_body_json = JSON.parse(response_body.to_s, :symbolize_names => true)
100
+ response_body_json = JSON.parse(response_body.to_s, symbolize_names: true)
123
101
  rescue
124
102
  # Failed to parse the response body as a json. Then, return an exception
125
103
  # without HTTP response information.
@@ -143,7 +121,11 @@ module Authlete
143
121
 
144
122
  body = response.body.to_s
145
123
 
146
- body.length == 0 ? nil : body
124
+ body.empty? ? nil : body
125
+ end
126
+
127
+ def on_general_exception(exception)
128
+ Authlete::Exception.new(message: exception.message)
147
129
  end
148
130
 
149
131
  def call_api_service_owner(method, path, content_type, payload)
@@ -176,26 +158,10 @@ module Authlete
176
158
  end
177
159
  end
178
160
 
179
- def emit_rack_error_message(request, message)
180
- begin
181
- # Logging if possible.
182
- request.env['rack.errors'].write("ERROR: #{message}\n")
183
- rescue => e
184
- end
185
- end
186
-
187
161
  def to_query(params)
188
- if params.nil? || params.size == 0
189
- return ""
190
- end
191
-
192
- array = []
162
+ return '' if params.nil? or params.empty?
193
163
 
194
- params.each do |key, value|
195
- array.push("#{key}=#{value}")
196
- end
197
-
198
- "?" + array.join("&")
164
+ '?' + params.map { |k, v| "#{k.to_s}=#{v.to_s}" }.join('&')
199
165
  end
200
166
 
201
167
  def to_hash(object)
@@ -206,442 +172,299 @@ module Authlete
206
172
  return object.to_hash if object.respond_to?('to_hash')
207
173
 
208
174
  # Otherwise, raise an exception.
209
- Authlete::Exception.new(:message => "Failed to convert the object to a hash.")
175
+ Authlete::Exception.new(message: "Failed to convert the object to a hash.")
176
+ end
177
+
178
+ def extract_requestable_scopes(hash)
179
+ hash.kind_of?(Hash) ? hash[:requestableScopes] : nil
210
180
  end
211
181
 
212
182
  public
213
183
 
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
184
  def authorization(request)
221
185
  hash = call_api_json_service("/api/auth/authorization", to_hash(request))
222
186
 
223
187
  Authlete::Model::Response::AuthorizationResponse.new(hash)
224
188
  end
225
189
 
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
190
  def authorization_issue(request)
233
191
  hash = call_api_json_service("/api/auth/authorization/issue", to_hash(request))
234
192
 
235
193
  Authlete::Model::Response::AuthorizationIssueResponse.new(hash)
236
194
  end
237
195
 
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
196
  def authorization_fail(request)
245
197
  hash = call_api_json_service("/api/auth/authorization/fail", to_hash(request))
246
198
 
247
199
  Authlete::Model::Response::AuthorizationFailResponse.new(hash)
248
200
  end
249
201
 
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
202
  def token(request)
257
203
  hash = call_api_json_service("/api/auth/token", to_hash(request))
258
204
 
259
205
  Authlete::Model::Response::TokenResponse.new(hash)
260
206
  end
261
207
 
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
208
  def token_issue(request)
269
209
  hash = call_api_json_service("/api/auth/token/issue", to_hash(request))
270
210
 
271
211
  Authlete::Model::Response::TokenIssueResponse.new(hash)
272
212
  end
273
213
 
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
214
  def token_fail(request)
281
215
  hash = call_api_json_service("/api/auth/token/fail", to_hash(request))
282
216
 
283
217
  Authlete::Model::Response::TokenFailResponse.new(hash)
284
218
  end
285
219
 
286
- # Call Authlete's /api/service/creatable API.
287
- #
288
- # On success, an instance of Authlete::Model::Response::ServiceCreatableResponse is returned.
289
- # On error, Authlete::Exception is raised.
290
- def service_creatable
291
- hash = call_api_service_owner(:get, "/api/service/creatable", nil, nil)
292
-
293
- Authlete::Model::Response::ServiceCreatableResponse.new(hash)
294
- end
295
-
296
- # Call Authlete's /api/service/create API.
297
- #
298
- # <tt>service</tt> is the content of a new service to create. The type of
299
- # the given object is either <tt>Hash</tt> or any object which
300
- # responds to <tt>to_hash</tt>. In normal cases, Authlete::Model::Service
301
- # (which responds to <tt>to_hash</tt>) should be used.
302
- #
303
- # On success, an instance of Authlete::Model::ServiceList is returned.
304
- # On error, Authlete::Exception is raised.
305
220
  def service_create(service)
306
221
  hash = call_api_json_service_owner("/api/service/create", to_hash(service))
307
222
 
308
223
  Authlete::Model::Service.new(hash)
309
224
  end
310
225
 
311
- # Call Authlete's /api/service/delete/{api_key} API.
312
- #
313
- # On error, Authlete::Exception is raised.
314
226
  def service_delete(api_key)
315
227
  call_api_service_owner(:delete, "/api/service/delete/#{api_key}", nil, nil)
316
228
  end
317
229
 
318
- # Call Authlete's /api/service/get/{api_key} API.
319
- #
320
- # <tt>api_key</tt> is the API key of the service whose information
321
- # you want to get.
322
- #
323
- # On success, an instance of Authlete::Model::Service is returned.
324
- # On error, Authlete::Exception is raised.
325
230
  def service_get(api_key)
326
231
  hash = call_api_service_owner(:get, "/api/service/get/#{api_key}", nil, nil)
327
232
 
328
233
  Authlete::Model::Service.new(hash)
329
234
  end
330
235
 
331
- # Call Authlete's /api/service/get/list API.
332
- #
333
- # <tt>params</tt> is an optional hash which contains query parameters
334
- # for /api/service/get/list API. <tt>:start</tt> and <tt>:end</tt> are
335
- # a start index (inclusive) and an end index (exclusive), respectively.
336
- #
337
- # On success, an instance of Authlete::Model::ServiceList is returned.
338
- # On error, Authlete::Exception is raised.
339
236
  def service_get_list(params = nil)
340
237
  hash = call_api_service_owner(:get, "/api/service/get/list#{to_query(params)}", nil, nil)
341
238
 
342
- Authlete::Model::ServiceList.new(hash)
239
+ Authlete::Model::Response::ServiceListResponse.new(hash)
343
240
  end
344
241
 
345
- # Call Authlete's /api/service/update/{api_key} API.
346
- #
347
- # <tt>api_key</tt> is the API key of the service whose information
348
- # you want to get.
349
- #
350
- # <tt>service</tt> is the new content of the service. The type of
351
- # the given object is either <tt>Hash</tt> or any object which
352
- # responds to <tt>to_hash</tt>. In normal cases, Authlete::Model::Service
353
- # (which responds to <tt>to_hash</tt>) should be used.
354
- #
355
- # On success, an instance of Authlete::Model::Service is returned.
356
- # On error, Authlete::Exception is raised.
357
242
  def service_update(api_key, service)
358
243
  hash = call_api_json_service_owner("/api/service/update/#{api_key}", to_hash(service))
359
244
 
360
245
  Authlete::Model::Service.new(hash)
361
246
  end
362
247
 
363
- # Call Authlete's /api/serviceowner/get/self API.
364
- #
365
- # On success, an instance of Authlete::Model::ServiceOwner is returned.
366
- # On error, Authlete::Exception is raised.
367
248
  def serviceowner_get_self
368
249
  hash = call_api_service_owner(:get, "/api/serviceowner/get/self", nil, nil)
369
250
 
370
251
  Authlete::Model::ServiceOwner.new(hash)
371
252
  end
372
253
 
373
- # Call Authlete's /api/client/create API.
374
- #
375
- # <tt>client</tt> is the content of a new service to create. The type of
376
- # the given object is either <tt>Hash</tt> or any object which
377
- # responds to <tt>to_hash</tt>. In normal cases, Authlete::Model::Client
378
- # (which responds to <tt>to_hash</tt>) should be used.
379
- #
380
- # On success, an instance of Authlete::Model::ClientList is returned.
381
- # On error, Authlete::Exception is raised.
382
254
  def client_create(client)
383
255
  hash = call_api_json_service("/api/client/create", to_hash(client))
384
256
 
385
257
  Authlete::Model::Client.new(hash)
386
258
  end
387
259
 
388
- # Call Authlete's /api/client/delete/{clientId} API.
389
- #
390
- # <tt>client_id</tt> is the client ID of a client.
391
- #
392
- # On error, Authlete::Exception is raised.
393
260
  def client_delete(client_id)
394
261
  call_api_service(:delete, "/api/client/delete/#{client_id}", nil, nil)
395
262
  end
396
263
 
397
- # Call Authlete's /api/client/get/{clientId} API.
398
- #
399
- # <tt>client_id</tt> is the client ID of a client.
400
-
401
- # On success, an instance of Authlete::Model::Client is returned.
402
- # On error, Authlete::Exception is raised.
403
264
  def client_get(client_id)
404
265
  hash = call_api_service(:get, "/api/client/get/#{client_id}", nil, nil)
405
266
 
406
267
  Authlete::Model::Client.new(hash)
407
268
  end
408
269
 
409
- # Call Authlete's /api/client/get/list API.
410
- #
411
- # <tt>params</tt> is an optional hash which contains query parameters
412
- # for /api/client/get/list API. <tt>:start</tt> and <tt>:end</tt> are
413
- # a start index (inclusive) and an end index (exclusive), respectively.
414
- #
415
- # On success, an instance of Authlete::Model::ClientList is returned.
416
- # On error, Authlete::Exception is raised.
417
270
  def client_get_list(params = nil)
418
271
  hash = call_api_service(:get, "/api/client/get/list#{to_query(params)}", nil, nil)
419
272
 
420
- Authlete::Model::ClientList.new(hash)
273
+ Authlete::Model::Response::ClientListResponse.new(hash)
421
274
  end
422
275
 
423
- # Call Authlete's /api/client/update/{clientId} API.
424
- #
425
- # <tt>client</tt> is the new content of the client. The type of
426
- # the given object is either <tt>Hash</tt> or any object which
427
- # responds to <tt>to_hash</tt>. In normal cases, Authlete::Model::Client
428
- # (which responds to <tt>to_hash</tt>) should be used.
429
- #
430
- # On success, an instance of Authlete::Model::Client is returned.
431
- # On error, Authlete::Exception is raised.
432
276
  def client_update(client)
433
- hash = call_api_json_service("/api/client/update/#{client[:clientId]}", to_hash(client))
277
+ hash = call_api_json_service("/api/client/update/#{client.clientId}", to_hash(client))
434
278
 
435
279
  Authlete::Model::Client.new(hash)
436
280
  end
437
281
 
438
- # Call Authlete's /api/client/secret/refresh/{clientIdentifier} API.
439
- #
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.
443
- # On error, Authlete::Exception is raised.
444
282
  def refresh_client_secret(client_identifier)
445
283
  hash = call_api_service(:get, "/api/client/secret/refresh/#{client_identifier}", nil, nil)
446
284
 
447
285
  Authlete::Model::Response::ClientSecretRefreshResponse.new(hash)
448
286
  end
449
287
 
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
288
  def update_client_secret(client_identifier, client_secret)
458
- request = Authlete::Model::Request::ClientSecretUpdateRequest.new(:client_secret => client_secret)
289
+ request = Authlete::Model::Request::ClientSecretUpdateRequest.new(clientSecret: client_secret)
459
290
 
460
291
  hash = call_api_json_service("/api/client/secret/update/#{client_identifier}", request.to_hash)
461
292
 
462
293
  Authlete::Model::Response::ClientSecretUpdateResponse.new(hash)
463
294
  end
464
295
 
465
- # Call Authlete's /api/client/authorization/get/list API.
466
- #
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.
470
- # On error, Authlete::Exception is raised.
471
296
  def get_client_authorization_list(request)
472
297
  hash = call_api_json_service("/api/client/authorization/get/list", to_hash(request))
473
298
 
474
- Authlete::Model::Response::ClientAuthorizationListResponse.new(hash)
299
+ Authlete::Model::Response::AuthorizedClientListResponse.new(hash)
475
300
  end
476
301
 
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
302
  def update_client_authorization(client_id, request)
483
303
  call_api_json_service("/api/client/authorization/update/#{client_id}", to_hash(request))
484
304
  end
485
305
 
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.
490
- #
491
- # On error, Authlete::Exception is raised.
492
306
  def delete_client_authorization(client_id, subject)
493
- request = Authlete::Model::Request::ClientAuthorizationDeleteRequest.new(:subject => subject)
307
+ request = Authlete::Model::Request::ClientAuthorizationDeleteRequest.new(subject: subject)
494
308
 
495
309
  call_api_json_service("/api/client/authorization/delete/#{client_id}", request.to_hash)
496
310
  end
497
311
 
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
312
  def introspection(request)
505
313
  hash = call_api_json_service('/api/auth/introspection', to_hash(request))
506
314
 
507
315
  Authlete::Model::Response::IntrospectionResponse.new(hash)
508
316
  end
509
317
 
510
- # Call Authlete's /api/auth/introspection/standard API.
511
- #
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.
515
- # On error, Authlete::Exception is raised.
516
318
  def standard_introspection(request)
517
319
  hash = call_api_json_service('/api/auth/introspection/standard', to_hash(request))
518
320
 
519
321
  Authlete::Model::Response::StandardIntrospectionResponse.new(hash)
520
322
  end
521
323
 
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
324
  def revocation(request)
529
325
  hash = call_api_json_service("/api/auth/revocation", to_hash(request))
530
326
 
531
327
  Authlete::Model::Response::RevocationResponse.new(hash)
532
328
  end
533
329
 
534
- # Call Authlete's /api/auth/userinfo API.
535
- #
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.
539
- # On error, Authlete::Exception is raised.
540
330
  def user_info(request)
541
331
  hash = call_api_json_service("/api/auth/userinfo", to_hash(request))
542
332
 
543
333
  Authlete::Model::Response::UserInfoResponse.new(hash)
544
334
  end
545
335
 
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
336
  def user_info_issue(request)
553
337
  hash = call_api_json_service("/api/auth/userinfo/issue", to_hash(request))
554
338
 
555
339
  Authlete::Model::Response::UserInfoIssueResponse.new(hash)
556
340
  end
557
341
 
558
- # Call Authlete's /api/service/jwks/get API.
559
- #
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.
574
- # On error, Authlete::Exception is raised.
575
342
  def get_service_jwks(params = nil)
576
343
  call_api_service(:get, "/api/service/jwks/get#{to_query(params)}", nil, nil)
577
344
  end
578
345
 
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
346
  def get_service_configuration(params = nil)
593
347
  call_api_service(:get, "/api/service/configuration#{to_query(params)}", nil, nil)
594
348
  end
595
349
 
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
350
  def token_create(request)
603
351
  hash = call_api_json_service("/api/auth/token/create", to_hash(request))
604
352
 
605
353
  Authlete::Model::Response::TokenCreateResponse.new(hash)
606
354
  end
607
355
 
608
- # Call Authlete's /api/auth/token/update API.
609
- #
610
- # <tt>request</tt> is an instance of Authlete::Model::Request::TokenUpdateRequest.
611
- #
612
- # On success, an instance of Authlete::Model::Response::TokenUpdateResponse is returned.
613
- # On error, Authlete::Exception is raised.
614
356
  def token_update(request)
615
357
  hash = call_api_json_service("/api/auth/token/update", to_hash(request))
616
358
 
617
359
  Authlete::Model::Response::TokenUpdateResponse.new(hash)
618
360
  end
619
361
 
620
- # Call Authlete's /api/client/granted_scopes/get/{clientId} API.
621
- #
622
- # <tt>client_id</tt> is the client ID of a client.
623
- # <tt>subject</tt> is the unique ID of an end user.
624
- #
625
- # On success, an instance of Authlete::Model::Response::GrantedScopesGetResponse is returned.
626
- # On error, Authlete::Exception is raised.
362
+ def get_token_list(params = nil)
363
+ hash = call_api_service(:get, "/api/auth/token/get/list#{to_query(params)}", nil, nil)
364
+
365
+ Authlete::Model::Response::TokenListResponse.new(hash)
366
+ end
367
+
627
368
  def get_granted_scopes(client_id, subject)
628
- request = Authlete::Model::Request::GrantedScopesRequest.new(:subject => subject)
369
+ request = Authlete::Model::Request::GrantedScopesRequest.new(subject: subject)
629
370
 
630
- hash = call_api_json_service("/api/client/granted_scopes/get/#{client_id}", request.to_hash)
371
+ hash = call_api_json_service("/api/client/granted_scopes/get/#{client_id}", to_hash(request))
631
372
 
632
373
  Authlete::Model::Response::GrantedScopesGetResponse.new(hash)
633
374
  end
634
375
 
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
376
  def delete_granted_scopes(client_id, subject)
642
- request = Authlete::Model::Request::GrantedScopesRequest.new(:subject => subject)
377
+ request = Authlete::Model::Request::GrantedScopesRequest.new(subject: subject)
378
+
379
+ call_api_json_service("/api/client/granted_scopes/delete/#{client_id}", to_hash(request))
380
+ end
381
+
382
+ def get_requestable_scopes(client_id)
383
+ hash = call_api_service(:get, "/api/client/extension/requestable_scopes/get/#{client_id}", nil, nil)
384
+
385
+ extract_requestable_scopes(hash)
386
+ end
387
+
388
+ def set_requestable_scopes(client_id, scopes)
389
+ hash = call_api_json_service("/api/client/extension/requestable_scopes/update/#{client_id}", { requestableScopes: scopes })
643
390
 
644
- call_api_json_service("/api/client/granted_scopes/delete/#{client_id}", request.to_hash)
391
+ extract_requestable_scopes(hash)
392
+ end
393
+
394
+ def delete_requestable_scopes(client_id)
395
+ call_api_service(:delete, "/api/client/extension/requestable_scopes/delete/#{client_id}", nil, nil)
396
+ end
397
+
398
+ def dynamic_client_register(request)
399
+ hash = call_api_json_service("/api/client/registration", to_hash(request))
400
+
401
+ Authlete::Model::Response::ClientRegistrationResponse.new(hash)
402
+ end
403
+
404
+ def dynamic_client_get(request)
405
+ hash = call_api_json_service("/api/client/registration/get", to_hash(request))
406
+
407
+ Authlete::Model::Response::ClientRegistrationResponse.new(hash)
408
+ end
409
+
410
+ def dynamic_client_update(request)
411
+ hash = call_api_json_service("/api/client/registration/update", to_hash(request))
412
+
413
+ Authlete::Model::Response::ClientRegistrationResponse.new(hash)
414
+ end
415
+
416
+ def dynamic_client_delete(request)
417
+ hash = call_api_json_service("/api/client/registration/delete", to_hash(request))
418
+
419
+ Authlete::Model::Response::ClientRegistrationResponse.new(hash)
420
+ end
421
+
422
+ def backchannel_authentication(request)
423
+ hash = call_api_json_service("/api/backchannel/authentication", to_hash(request))
424
+
425
+ Authlete::Model::Response::BackchannelAuthenticationResponse.new(hash)
426
+ end
427
+
428
+ def backchannel_authentication_issue(request)
429
+ hash = call_api_json_service("/api/backchannel/authentication/issue", to_hash(request))
430
+
431
+ Authlete::Model::Response::BackchannelAuthenticationIssueResponse.new(hash)
432
+ end
433
+
434
+ def backchannel_authentication_fail(request)
435
+ hash = call_api_json_service("/api/backchannel/authentication/fail", to_hash(request))
436
+
437
+ Authlete::Model::Response::BackchannelAuthenticationFailResponse.new(hash)
438
+ end
439
+
440
+ def backchannel_authentication_complete(request)
441
+ hash = call_api_json_service("/api/backchannel/authentication/complete", to_hash(request))
442
+
443
+ Authlete::Model::Response::BackchannelAuthenticationCompleteResponse.new(hash)
444
+ end
445
+
446
+ def device_authorization(request)
447
+ hash = call_api_json_service("/api/device/authorization", to_hash(request))
448
+
449
+ Authlete::Model::Response::DeviceAuthorizationResponse.new(hash)
450
+ end
451
+
452
+ def device_complete(request)
453
+ hash = call_api_json_service("/api/device/complete", to_hash(request))
454
+
455
+ Authlete::Model::Response::DeviceCompleteResponse.new(hash)
456
+ end
457
+
458
+ def device_verification(request)
459
+ hash = call_api_json_service("/api/device/verification", to_hash(request))
460
+
461
+ Authlete::Model::Response::DeviceVerificationResponse.new(hash)
462
+ end
463
+
464
+ def push_authorization_request(request)
465
+ hash = call_api_json_service("/api/pushed_auth_req", to_hash(request))
466
+
467
+ Authlete::Model::Response::PushedAuthReqResponse.new(hash)
645
468
  end
646
469
 
647
470
  # Ensure that the request contains a valid access token.
@@ -674,16 +497,16 @@ module Authlete
674
497
  if access_token.nil?
675
498
  # The request does not contain a valid access token.
676
499
  return Authlete::Model::Response::IntrospectionResponse.new(
677
- :action => 'BAD_REQUEST',
678
- :responseContent => 'Bearer error="invalid_token",error_description="The request does not contain a valid access token."'
500
+ action: 'BAD_REQUEST',
501
+ responseContent: 'Bearer error="invalid_token",error_description="The request does not contain a valid access token."'
679
502
  )
680
503
  end
681
504
 
682
505
  # Create a request for Authlete's /api/auth/introspection API.
683
506
  request = Authlete::Model::Request::IntrospectionRequest.new(
684
- :token => access_token,
685
- :scopes => scopes,
686
- :subject => subject
507
+ token: access_token,
508
+ scopes: scopes,
509
+ subject: subject
687
510
  )
688
511
 
689
512
  begin
@@ -698,13 +521,21 @@ module Authlete
698
521
 
699
522
  # Failed to introspect the access token.
700
523
  return Authlete::Model::Response::IntrospectionResponse.new(
701
- :action => 'INTERNAL_SERVER_ERROR',
702
- :responseContent => "Bearer error=\"server_error\",error_description=\"#{message}\""
524
+ action: 'INTERNAL_SERVER_ERROR',
525
+ responseContent: "Bearer error=\"server_error\",error_description=\"#{message}\""
703
526
  )
704
527
  end
705
528
 
706
529
  # Return the response from Authlete's /api/auth/introspection API.
707
530
  result
708
531
  end
532
+
533
+ def emit_rack_error_message(request, message)
534
+ begin
535
+ # Logging if possible.
536
+ request.env['rack.errors'].write("ERROR: #{message}\n")
537
+ rescue => e
538
+ end
539
+ end
709
540
  end
710
- end
541
+ end