authlete 1.0.24 → 1.1.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 +4 -4
  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 +146 -321
  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 +196 -345
  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 +464 -685
  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 +95 -0
  145. data/test/authlete/model/test_client.rb +461 -0
  146. data/test/authlete/model/test_named-uri.rb +85 -0
  147. data/test/authlete/model/test_pair.rb +85 -0
  148. data/test/authlete/model/test_property.rb +90 -0
  149. data/test/authlete/model/test_result.rb +68 -0
  150. data/test/authlete/model/test_scope.rb +106 -0
  151. data/test/authlete/model/test_service-owner.rb +80 -0
  152. data/test/authlete/model/test_service.rb +614 -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 +169 -9
  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
2
  SHA1:
3
- metadata.gz: ec596fd6d870c0035ee2425fa46196ac1b52a9d6
4
- data.tar.gz: 059948b5a01074063771f602d1860c4d8c0f0c3f
3
+ metadata.gz: cb006019176ce727d7082df01b8dfb203196355f
4
+ data.tar.gz: 8d2ceba5ad8a6c3c558e06d78a709fff67db068e
5
5
  SHA512:
6
- metadata.gz: bebb3f3c4d4426362ca20d5a04432520c2aacad9067fe5e7070bdd1c8c46d372c5be4ae0d5141933f468810a4524c27b2208ef090607d0b94cfc35db4329602c
7
- data.tar.gz: e00b22aa7280f7145f3752b1c89ac441de7a98df45f471cef88538049cc9cb28359d90cee4cddbf87feb58d88b1d6a4b81b2df2ece252ad8b6eb4c4dc4e09d04
6
+ metadata.gz: 24e8bdbe35decd978515837684ab16c8e264a431a1ff0d33ed5372bbdb93c83ce9a118810c17ac5984d72ac92d29933e6e4ad59870c0c187a45c4f59c79965a2
7
+ data.tar.gz: d13c223cec60659b62309f4f1ace44800666a6d09518e7ac575f22b7964ac94210b1c7c86170723783b0c50d850abcdd391d7cc8779e32e49a0504f59ac9106f
data/.gitignore CHANGED
@@ -12,4 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
- .idea/
15
+ .idea/
16
+ .DS_Store
@@ -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
@@ -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/"
@@ -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
@@ -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,70 +21,46 @@ 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)
@@ -102,7 +78,7 @@ module Authlete
102
78
  response = exception.response
103
79
 
104
80
  # Create a base exception.
105
- authlete_exception = Authlete::Exception.new(:message => message)
81
+ authlete_exception = Authlete::Exception.new(message: message)
106
82
 
107
83
  if response.nil?
108
84
  # No response information. Then, return an exception without HTTP
@@ -121,7 +97,7 @@ module Authlete
121
97
 
122
98
  begin
123
99
  # Parse the response body as a json.
124
- 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)
125
101
  rescue
126
102
  # Failed to parse the response body as a json. Then, return an exception
127
103
  # without HTTP response information.
@@ -145,11 +121,11 @@ module Authlete
145
121
 
146
122
  body = response.body.to_s
147
123
 
148
- body.length == 0 ? nil : body
124
+ body.empty? ? nil : body
149
125
  end
150
126
 
151
127
  def on_general_exception(exception)
152
- Authlete::Exception.new(:message => exception.message)
128
+ Authlete::Exception.new(message: exception.message)
153
129
  end
154
130
 
155
131
  def call_api_service_owner(method, path, content_type, payload)
@@ -182,26 +158,10 @@ module Authlete
182
158
  end
183
159
  end
184
160
 
185
- def emit_rack_error_message(request, message)
186
- begin
187
- # Logging if possible.
188
- request.env['rack.errors'].write("ERROR: #{message}\n")
189
- rescue => e
190
- end
191
- end
192
-
193
161
  def to_query(params)
194
- if params.nil? || params.size == 0
195
- return ""
196
- end
197
-
198
- array = []
199
-
200
- params.each do |key, value|
201
- array.push("#{key}=#{value}")
202
- end
162
+ return '' if params.nil? or params.empty?
203
163
 
204
- "?" + array.join("&")
164
+ '?' + params.map { |k, v| "#{k.to_s}=#{v.to_s}" }.join('&')
205
165
  end
206
166
 
207
167
  def to_hash(object)
@@ -212,442 +172,299 @@ module Authlete
212
172
  return object.to_hash if object.respond_to?('to_hash')
213
173
 
214
174
  # Otherwise, raise an exception.
215
- 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
216
180
  end
217
181
 
218
182
  public
219
183
 
220
- # Call Authlete's /api/auth/authorization API.
221
- #
222
- # <tt>request</tt> is an instance of Authlete::Model::Request::AuthorizationRequest.
223
- #
224
- # On success, an instance of Authlete::Model::Response::AuthorizationResponse is returned.
225
- # On error, Authlete::Exception is raised.
226
184
  def authorization(request)
227
185
  hash = call_api_json_service("/api/auth/authorization", to_hash(request))
228
186
 
229
187
  Authlete::Model::Response::AuthorizationResponse.new(hash)
230
188
  end
231
189
 
232
- # Call Authlete's /api/auth/authorization/issue API.
233
- #
234
- # <tt>request</tt> is an instance of Authlete::Model::Request::AuthorizationIssueRequest.
235
- #
236
- # On success, an instance of Authlete::Model::Response::AuthorizationIssueResponse is returned.
237
- # On error, Authlete::Exception is raised.
238
190
  def authorization_issue(request)
239
191
  hash = call_api_json_service("/api/auth/authorization/issue", to_hash(request))
240
192
 
241
193
  Authlete::Model::Response::AuthorizationIssueResponse.new(hash)
242
194
  end
243
195
 
244
- # Call Authlete's /api/auth/authorization/fail API.
245
- #
246
- # <tt>request</tt> is an instance of Authlete::Model::Request::AuthorizationFailRequest.
247
- #
248
- # On success, an instance of Authlete::Model::Response::AuthorizationFailResponse is returned.
249
- # On error, Authlete::Exception is raised.
250
196
  def authorization_fail(request)
251
197
  hash = call_api_json_service("/api/auth/authorization/fail", to_hash(request))
252
198
 
253
199
  Authlete::Model::Response::AuthorizationFailResponse.new(hash)
254
200
  end
255
201
 
256
- # Call Authlete's /api/auth/token API.
257
- #
258
- # <tt>request</tt> is an instance of Authlete::Model::Request::TokenRequest.
259
- #
260
- # On success, an instance of Authlete::Model::Response::TokenResponse is returned.
261
- # On error, Authlete::Exception is raised.
262
202
  def token(request)
263
203
  hash = call_api_json_service("/api/auth/token", to_hash(request))
264
204
 
265
205
  Authlete::Model::Response::TokenResponse.new(hash)
266
206
  end
267
207
 
268
- # Call Authlete's /api/auth/token/issue API.
269
- #
270
- # <tt>request</tt> is an instance of Authlete::Model::Request::TokenIssueRequest.
271
- #
272
- # On success, an instance of Authlete::Model::Response::TokenIssueResponse is returned.
273
- # On error, Authlete::Exception is raised.
274
208
  def token_issue(request)
275
209
  hash = call_api_json_service("/api/auth/token/issue", to_hash(request))
276
210
 
277
211
  Authlete::Model::Response::TokenIssueResponse.new(hash)
278
212
  end
279
213
 
280
- # Call Authlete's /api/auth/token/fail API.
281
- #
282
- # <tt>request</tt> is an instance of Authlete::Model::Request::TokenFailRequest.
283
- #
284
- # On success, an instance of Authlete::Model::Response::TokenFailResponse is returned.
285
- # On error, Authlete::Exception is raised.
286
214
  def token_fail(request)
287
215
  hash = call_api_json_service("/api/auth/token/fail", to_hash(request))
288
216
 
289
217
  Authlete::Model::Response::TokenFailResponse.new(hash)
290
218
  end
291
219
 
292
- # Call Authlete's /api/service/creatable API.
293
- #
294
- # On success, an instance of Authlete::Model::Response::ServiceCreatableResponse is returned.
295
- # On error, Authlete::Exception is raised.
296
- def service_creatable
297
- hash = call_api_service_owner(:get, "/api/service/creatable", nil, nil)
298
-
299
- Authlete::Model::Response::ServiceCreatableResponse.new(hash)
300
- end
301
-
302
- # Call Authlete's /api/service/create API.
303
- #
304
- # <tt>service</tt> is the content of a new service to create. The type of
305
- # the given object is either <tt>Hash</tt> or any object which
306
- # responds to <tt>to_hash</tt>. In normal cases, Authlete::Model::Service
307
- # (which responds to <tt>to_hash</tt>) should be used.
308
- #
309
- # On success, an instance of Authlete::Model::ServiceList is returned.
310
- # On error, Authlete::Exception is raised.
311
220
  def service_create(service)
312
221
  hash = call_api_json_service_owner("/api/service/create", to_hash(service))
313
222
 
314
223
  Authlete::Model::Service.new(hash)
315
224
  end
316
225
 
317
- # Call Authlete's /api/service/delete/{api_key} API.
318
- #
319
- # On error, Authlete::Exception is raised.
320
226
  def service_delete(api_key)
321
227
  call_api_service_owner(:delete, "/api/service/delete/#{api_key}", nil, nil)
322
228
  end
323
229
 
324
- # Call Authlete's /api/service/get/{api_key} API.
325
- #
326
- # <tt>api_key</tt> is the API key of the service whose information
327
- # you want to get.
328
- #
329
- # On success, an instance of Authlete::Model::Service is returned.
330
- # On error, Authlete::Exception is raised.
331
230
  def service_get(api_key)
332
231
  hash = call_api_service_owner(:get, "/api/service/get/#{api_key}", nil, nil)
333
232
 
334
233
  Authlete::Model::Service.new(hash)
335
234
  end
336
235
 
337
- # Call Authlete's /api/service/get/list API.
338
- #
339
- # <tt>params</tt> is an optional hash which contains query parameters
340
- # for /api/service/get/list API. <tt>:start</tt> and <tt>:end</tt> are
341
- # a start index (inclusive) and an end index (exclusive), respectively.
342
- #
343
- # On success, an instance of Authlete::Model::ServiceList is returned.
344
- # On error, Authlete::Exception is raised.
345
236
  def service_get_list(params = nil)
346
237
  hash = call_api_service_owner(:get, "/api/service/get/list#{to_query(params)}", nil, nil)
347
238
 
348
- Authlete::Model::ServiceList.new(hash)
239
+ Authlete::Model::Response::ServiceListResponse.new(hash)
349
240
  end
350
241
 
351
- # Call Authlete's /api/service/update/{api_key} API.
352
- #
353
- # <tt>api_key</tt> is the API key of the service whose information
354
- # you want to get.
355
- #
356
- # <tt>service</tt> is the new content of the service. The type of
357
- # the given object is either <tt>Hash</tt> or any object which
358
- # responds to <tt>to_hash</tt>. In normal cases, Authlete::Model::Service
359
- # (which responds to <tt>to_hash</tt>) should be used.
360
- #
361
- # On success, an instance of Authlete::Model::Service is returned.
362
- # On error, Authlete::Exception is raised.
363
242
  def service_update(api_key, service)
364
243
  hash = call_api_json_service_owner("/api/service/update/#{api_key}", to_hash(service))
365
244
 
366
245
  Authlete::Model::Service.new(hash)
367
246
  end
368
247
 
369
- # Call Authlete's /api/serviceowner/get/self API.
370
- #
371
- # On success, an instance of Authlete::Model::ServiceOwner is returned.
372
- # On error, Authlete::Exception is raised.
373
248
  def serviceowner_get_self
374
249
  hash = call_api_service_owner(:get, "/api/serviceowner/get/self", nil, nil)
375
250
 
376
251
  Authlete::Model::ServiceOwner.new(hash)
377
252
  end
378
253
 
379
- # Call Authlete's /api/client/create API.
380
- #
381
- # <tt>client</tt> is the content of a new service to create. The type of
382
- # the given object is either <tt>Hash</tt> or any object which
383
- # responds to <tt>to_hash</tt>. In normal cases, Authlete::Model::Client
384
- # (which responds to <tt>to_hash</tt>) should be used.
385
- #
386
- # On success, an instance of Authlete::Model::ClientList is returned.
387
- # On error, Authlete::Exception is raised.
388
254
  def client_create(client)
389
255
  hash = call_api_json_service("/api/client/create", to_hash(client))
390
256
 
391
257
  Authlete::Model::Client.new(hash)
392
258
  end
393
259
 
394
- # Call Authlete's /api/client/delete/{clientId} API.
395
- #
396
- # <tt>client_id</tt> is the client ID of a client.
397
- #
398
- # On error, Authlete::Exception is raised.
399
260
  def client_delete(client_id)
400
261
  call_api_service(:delete, "/api/client/delete/#{client_id}", nil, nil)
401
262
  end
402
263
 
403
- # Call Authlete's /api/client/get/{clientId} API.
404
- #
405
- # <tt>client_id</tt> is the client ID of a client.
406
-
407
- # On success, an instance of Authlete::Model::Client is returned.
408
- # On error, Authlete::Exception is raised.
409
264
  def client_get(client_id)
410
265
  hash = call_api_service(:get, "/api/client/get/#{client_id}", nil, nil)
411
266
 
412
267
  Authlete::Model::Client.new(hash)
413
268
  end
414
269
 
415
- # Call Authlete's /api/client/get/list API.
416
- #
417
- # <tt>params</tt> is an optional hash which contains query parameters
418
- # for /api/client/get/list API. <tt>:start</tt> and <tt>:end</tt> are
419
- # a start index (inclusive) and an end index (exclusive), respectively.
420
- #
421
- # On success, an instance of Authlete::Model::ClientList is returned.
422
- # On error, Authlete::Exception is raised.
423
270
  def client_get_list(params = nil)
424
271
  hash = call_api_service(:get, "/api/client/get/list#{to_query(params)}", nil, nil)
425
272
 
426
- Authlete::Model::ClientList.new(hash)
273
+ Authlete::Model::Response::ClientListResponse.new(hash)
427
274
  end
428
275
 
429
- # Call Authlete's /api/client/update/{clientId} API.
430
- #
431
- # <tt>client</tt> is the new content of the client. The type of
432
- # the given object is either <tt>Hash</tt> or any object which
433
- # responds to <tt>to_hash</tt>. In normal cases, Authlete::Model::Client
434
- # (which responds to <tt>to_hash</tt>) should be used.
435
- #
436
- # On success, an instance of Authlete::Model::Client is returned.
437
- # On error, Authlete::Exception is raised.
438
276
  def client_update(client)
439
- 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))
440
278
 
441
279
  Authlete::Model::Client.new(hash)
442
280
  end
443
281
 
444
- # Call Authlete's /api/client/secret/refresh/{clientIdentifier} API.
445
- #
446
- # <tt>clientIdentifier</tt> is the client ID or the client ID alias of a client.
447
- #
448
- # On success, an instance of Authlete::Model::Response::ClientSecretRefreshResponse is returned.
449
- # On error, Authlete::Exception is raised.
450
282
  def refresh_client_secret(client_identifier)
451
283
  hash = call_api_service(:get, "/api/client/secret/refresh/#{client_identifier}", nil, nil)
452
284
 
453
285
  Authlete::Model::Response::ClientSecretRefreshResponse.new(hash)
454
286
  end
455
287
 
456
- # Call Authlete's /api/client/secret/update/{clientIdentifier} API.
457
- #
458
- # <tt>client_identifier</tt> is the client ID or the client ID alias of a client.
459
- # <tt>client_secret</tt> is the client secret of a client.
460
- #
461
- # On success, an instance of Authlete::Model::Response::ClientSecretUpdateResponse is returned.
462
- # On error, Authlete::Exception is raised.
463
288
  def update_client_secret(client_identifier, client_secret)
464
- request = Authlete::Model::Request::ClientSecretUpdateRequest.new(:client_secret => client_secret)
289
+ request = Authlete::Model::Request::ClientSecretUpdateRequest.new(clientSecret: client_secret)
465
290
 
466
291
  hash = call_api_json_service("/api/client/secret/update/#{client_identifier}", request.to_hash)
467
292
 
468
293
  Authlete::Model::Response::ClientSecretUpdateResponse.new(hash)
469
294
  end
470
295
 
471
- # Call Authlete's /api/client/authorization/get/list API.
472
- #
473
- # <tt>request</tt> is an instance of Authlete::Model::Request::ClientSecretUpdateRequest.
474
- #
475
- # On success, an instance of Authlete::Model::Response::ClientAuthorizationListResponse is returned.
476
- # On error, Authlete::Exception is raised.
477
296
  def get_client_authorization_list(request)
478
297
  hash = call_api_json_service("/api/client/authorization/get/list", to_hash(request))
479
298
 
480
- Authlete::Model::Response::ClientAuthorizationListResponse.new(hash)
299
+ Authlete::Model::Response::AuthorizedClientListResponse.new(hash)
481
300
  end
482
301
 
483
- # Call Authlete's /api/client/authorization/update API.
484
- #
485
- # <tt>request</tt> is an instance of Authlete::Model::Request::ClientSecretUpdateRequest.
486
- #
487
- # On error, Authlete::Exception is raised.
488
302
  def update_client_authorization(client_id, request)
489
303
  call_api_json_service("/api/client/authorization/update/#{client_id}", to_hash(request))
490
304
  end
491
305
 
492
- # Call Authlete's /api/client/authorization/delete/{clientId} API.
493
- #
494
- # <tt>client_id</tt> is the client ID of a client.
495
- # <tt>subject</tt> is the unique ID of an end user.
496
- #
497
- # On error, Authlete::Exception is raised.
498
306
  def delete_client_authorization(client_id, subject)
499
- request = Authlete::Model::Request::ClientAuthorizationDeleteRequest.new(:subject => subject)
307
+ request = Authlete::Model::Request::ClientAuthorizationDeleteRequest.new(subject: subject)
500
308
 
501
309
  call_api_json_service("/api/client/authorization/delete/#{client_id}", request.to_hash)
502
310
  end
503
311
 
504
- # Call Authlete's /api/auth/introspection API.
505
- #
506
- # <tt>request</tt> is an instance of Authlete::Model::Request::IntrospectionRequest.
507
- #
508
- # On success, an instance of Authlete::Model::Response::IntrospectionResponse is returned.
509
- # On error, Authlete::Exception is raised.
510
312
  def introspection(request)
511
313
  hash = call_api_json_service('/api/auth/introspection', to_hash(request))
512
314
 
513
315
  Authlete::Model::Response::IntrospectionResponse.new(hash)
514
316
  end
515
317
 
516
- # Call Authlete's /api/auth/introspection/standard API.
517
- #
518
- # <tt>request</tt> is an instance of Authlete::Model::Request::StandardIntrospectionRequest.
519
- #
520
- # On success, an instance of Authlete::Model::Response::StandardIntrospectionResponse is returned.
521
- # On error, Authlete::Exception is raised.
522
318
  def standard_introspection(request)
523
319
  hash = call_api_json_service('/api/auth/introspection/standard', to_hash(request))
524
320
 
525
321
  Authlete::Model::Response::StandardIntrospectionResponse.new(hash)
526
322
  end
527
323
 
528
- # Call Authlete's /api/auth/revocation API.
529
- #
530
- # <tt>request</tt> is an instance of Authlete::Model::Request::RevocationRequest.
531
- #
532
- # On success, an instance of Authlete::Model::Response::RevocationResponse is returned.
533
- # On error, Authlete::Exception is raised.
534
324
  def revocation(request)
535
325
  hash = call_api_json_service("/api/auth/revocation", to_hash(request))
536
326
 
537
327
  Authlete::Model::Response::RevocationResponse.new(hash)
538
328
  end
539
329
 
540
- # Call Authlete's /api/auth/userinfo API.
541
- #
542
- # <tt>request</tt> is an instance of Authlete::Model::Request::UserInfoRequest.
543
- #
544
- # On success, an instance of Authlete::Model::Response::UserInfoResponse is returned.
545
- # On error, Authlete::Exception is raised.
546
330
  def user_info(request)
547
331
  hash = call_api_json_service("/api/auth/userinfo", to_hash(request))
548
332
 
549
333
  Authlete::Model::Response::UserInfoResponse.new(hash)
550
334
  end
551
335
 
552
- # Call Authlete's /api/auth/userinfo/issue API.
553
- #
554
- # <tt>request</tt> is an instance of Authlete::Model::Request::UserInfoIssueRequest.
555
- #
556
- # On success, an instance of Authlete::Model::Response::UserInfoIssueResponse is returned.
557
- # On error, Authlete::Exception is raised.
558
336
  def user_info_issue(request)
559
337
  hash = call_api_json_service("/api/auth/userinfo/issue", to_hash(request))
560
338
 
561
339
  Authlete::Model::Response::UserInfoIssueResponse.new(hash)
562
340
  end
563
341
 
564
- # Call Authlete's /api/service/jwks/get API.
565
- #
566
- # <tt>params</tt> is an optional hash which contains query parameters
567
- # for /api/service/jwks/get API. The hash can contain the following parameters.
568
- #
569
- # <tt>:includePrivateKeys</tt>
570
- # This boolean value indicates whether the response should include the
571
- # private keys associated with the service or not. If "true", the private
572
- # keys are included in the response. The default value is "false".
573
- #
574
- # <tt>:pretty</tt>
575
- # This boolean value indicates whether the JSON in the response should
576
- # be formatted or not. If true, the JSON in the response is pretty-formatted.
577
- # The default value is false.
578
- #
579
- # On success, a JWK Set for a service is returned.
580
- # On error, Authlete::Exception is raised.
581
342
  def get_service_jwks(params = nil)
582
343
  call_api_service(:get, "/api/service/jwks/get#{to_query(params)}", nil, nil)
583
344
  end
584
345
 
585
- # Call Authlete's /api/service/configuration API.
586
- #
587
- # <tt>params</tt> is an optional hash which contains query parameters
588
- # for /api/service/configuration API. The hash can contain the following
589
- # parameter.
590
- #
591
- # <tt>:includePrivateKeys</tt>
592
- # This boolean value indicates whether the response should include the
593
- # private keys associated with the service or not. If "true", the private
594
- # keys are included in the response. The default value is "false".
595
- #
596
- # On success, configuration information of a service is returned.
597
- # On error, Authlete::Exception is raised.
598
346
  def get_service_configuration(params = nil)
599
347
  call_api_service(:get, "/api/service/configuration#{to_query(params)}", nil, nil)
600
348
  end
601
349
 
602
- # Call Authlete's /api/auth/token/create API.
603
- #
604
- # <tt>request</tt> is an instance of Authlete::Model::Request::TokenCreateRequest.
605
- #
606
- # On success, an instance of Authlete::Model::Response::TokenCreateResponse is returned.
607
- # On error, Authlete::Exception is raised.
608
350
  def token_create(request)
609
351
  hash = call_api_json_service("/api/auth/token/create", to_hash(request))
610
352
 
611
353
  Authlete::Model::Response::TokenCreateResponse.new(hash)
612
354
  end
613
355
 
614
- # Call Authlete's /api/auth/token/update API.
615
- #
616
- # <tt>request</tt> is an instance of Authlete::Model::Request::TokenUpdateRequest.
617
- #
618
- # On success, an instance of Authlete::Model::Response::TokenUpdateResponse is returned.
619
- # On error, Authlete::Exception is raised.
620
356
  def token_update(request)
621
357
  hash = call_api_json_service("/api/auth/token/update", to_hash(request))
622
358
 
623
359
  Authlete::Model::Response::TokenUpdateResponse.new(hash)
624
360
  end
625
361
 
626
- # Call Authlete's /api/client/granted_scopes/get/{clientId} API.
627
- #
628
- # <tt>client_id</tt> is the client ID of a client.
629
- # <tt>subject</tt> is the unique ID of an end user.
630
- #
631
- # On success, an instance of Authlete::Model::Response::GrantedScopesGetResponse is returned.
632
- # 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
+
633
368
  def get_granted_scopes(client_id, subject)
634
- request = Authlete::Model::Request::GrantedScopesRequest.new(:subject => subject)
369
+ request = Authlete::Model::Request::GrantedScopesRequest.new(subject: subject)
635
370
 
636
- 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))
637
372
 
638
373
  Authlete::Model::Response::GrantedScopesGetResponse.new(hash)
639
374
  end
640
375
 
641
- # Call Authlete's /api/client/granted_scopes/delete/{clientId} API.
642
- #
643
- # <tt>client_id</tt> is the client ID of a client.
644
- # <tt>subject</tt> is the unique ID of an end user.
645
- #
646
- # On error, Authlete::Exception is raised.
647
376
  def delete_granted_scopes(client_id, subject)
648
- 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 })
390
+
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))
649
418
 
650
- call_api_json_service("/api/client/granted_scopes/delete/#{client_id}", request.to_hash)
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)
651
468
  end
652
469
 
653
470
  # Ensure that the request contains a valid access token.
@@ -680,16 +497,16 @@ module Authlete
680
497
  if access_token.nil?
681
498
  # The request does not contain a valid access token.
682
499
  return Authlete::Model::Response::IntrospectionResponse.new(
683
- :action => 'BAD_REQUEST',
684
- :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."'
685
502
  )
686
503
  end
687
504
 
688
505
  # Create a request for Authlete's /api/auth/introspection API.
689
506
  request = Authlete::Model::Request::IntrospectionRequest.new(
690
- :token => access_token,
691
- :scopes => scopes,
692
- :subject => subject
507
+ token: access_token,
508
+ scopes: scopes,
509
+ subject: subject
693
510
  )
694
511
 
695
512
  begin
@@ -704,13 +521,21 @@ module Authlete
704
521
 
705
522
  # Failed to introspect the access token.
706
523
  return Authlete::Model::Response::IntrospectionResponse.new(
707
- :action => 'INTERNAL_SERVER_ERROR',
708
- :responseContent => "Bearer error=\"server_error\",error_description=\"#{message}\""
524
+ action: 'INTERNAL_SERVER_ERROR',
525
+ responseContent: "Bearer error=\"server_error\",error_description=\"#{message}\""
709
526
  )
710
527
  end
711
528
 
712
529
  # Return the response from Authlete's /api/auth/introspection API.
713
530
  result
714
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
715
540
  end
716
- end
541
+ end