authlete 1.0.20 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Makefile +40 -0
  4. data/README.md +20 -20
  5. data/Rakefile +5 -0
  6. data/authlete.gemspec +2 -2
  7. data/lib/authlete.rb +28 -9
  8. data/lib/authlete/api.rb +153 -322
  9. data/lib/authlete/authentication-server.rb +230 -230
  10. data/lib/authlete/exception.rb +14 -15
  11. data/lib/authlete/model/base.rb +30 -0
  12. data/lib/authlete/model/client-extension.rb +17 -119
  13. data/lib/authlete/model/client.rb +203 -338
  14. data/lib/authlete/model/hashable.rb +13 -33
  15. data/lib/authlete/model/named-uri.rb +13 -74
  16. data/lib/authlete/model/pair.rb +13 -74
  17. data/lib/authlete/model/param-initializer.rb +45 -0
  18. data/lib/authlete/model/property.rb +15 -85
  19. data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
  20. data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
  21. data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
  22. data/lib/authlete/model/request/authorization-request.rb +8 -73
  23. data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
  24. data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
  25. data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
  26. data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
  27. data/lib/authlete/model/request/base.rb +26 -0
  28. data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
  29. data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
  30. data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
  31. data/lib/authlete/model/request/client-registration-request.rb +49 -0
  32. data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
  33. data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
  34. data/lib/authlete/model/request/device-authorization-request.rb +63 -0
  35. data/lib/authlete/model/request/device-complete-request.rb +99 -0
  36. data/lib/authlete/model/request/device-verification-request.rb +40 -0
  37. data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
  38. data/lib/authlete/model/request/introspection-request.rb +24 -83
  39. data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
  40. data/lib/authlete/model/request/revocation-request.rb +14 -88
  41. data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
  42. data/lib/authlete/model/request/token-create-request.rb +52 -183
  43. data/lib/authlete/model/request/token-fail-request.rb +12 -74
  44. data/lib/authlete/model/request/token-issue-request.rb +22 -80
  45. data/lib/authlete/model/request/token-request.rb +44 -81
  46. data/lib/authlete/model/request/token-update-request.rb +35 -121
  47. data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
  48. data/lib/authlete/model/request/user-info-request.rb +25 -70
  49. data/lib/authlete/model/response/access-token.rb +96 -0
  50. data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
  51. data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
  52. data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
  53. data/lib/authlete/model/response/authorization-response.rb +97 -123
  54. data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
  55. data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
  56. data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
  57. data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
  58. data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
  59. data/lib/authlete/model/response/client-list-response.rb +58 -0
  60. data/lib/authlete/model/response/client-registration-response.rb +50 -0
  61. data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
  62. data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
  63. data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
  64. data/lib/authlete/model/response/device-authorization-response.rb +134 -0
  65. data/lib/authlete/model/response/device-complete-response.rb +39 -0
  66. data/lib/authlete/model/response/device-verification-response.rb +96 -0
  67. data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
  68. data/lib/authlete/model/response/introspection-response.rb +64 -58
  69. data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
  70. data/lib/authlete/model/response/revocation-response.rb +12 -15
  71. data/lib/authlete/model/response/service-list-response.rb +54 -0
  72. data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
  73. data/lib/authlete/model/response/token-create-response.rb +50 -55
  74. data/lib/authlete/model/response/token-fail-response.rb +14 -17
  75. data/lib/authlete/model/response/token-issue-response.rb +49 -62
  76. data/lib/authlete/model/response/token-list-response.rb +64 -0
  77. data/lib/authlete/model/response/token-response.rb +59 -79
  78. data/lib/authlete/model/response/token-update-response.rb +28 -23
  79. data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
  80. data/lib/authlete/model/response/user-info-response.rb +48 -42
  81. data/lib/authlete/model/result.rb +14 -13
  82. data/lib/authlete/model/scope.rb +68 -158
  83. data/lib/authlete/model/service-owner.rb +32 -116
  84. data/lib/authlete/model/service.rb +660 -830
  85. data/lib/authlete/model/sns-credentials.rb +51 -124
  86. data/lib/authlete/model/tagged-value.rb +14 -69
  87. data/lib/authlete/utility.rb +70 -99
  88. data/lib/authlete/version.rb +3 -3
  89. data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
  90. data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
  91. data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
  92. data/test/authlete/model/request/test_authorization-request.rb +57 -0
  93. data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
  94. data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
  95. data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
  96. data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
  97. data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
  98. data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
  99. data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
  100. data/test/authlete/model/request/test_client-registration-request.rb +68 -0
  101. data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
  102. data/test/authlete/model/request/test_device-complete-request.rb +102 -0
  103. data/test/authlete/model/request/test_device-verification-request.rb +57 -0
  104. data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
  105. data/test/authlete/model/request/test_introspection-request.rb +79 -0
  106. data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
  107. data/test/authlete/model/request/test_revocation-request.rb +67 -0
  108. data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
  109. data/test/authlete/model/request/test_token-create-request.rb +110 -0
  110. data/test/authlete/model/request/test_token-fail-request.rb +63 -0
  111. data/test/authlete/model/request/test_token-issue-request.rb +70 -0
  112. data/test/authlete/model/request/test_token-request.rb +94 -0
  113. data/test/authlete/model/request/test_token-update-request.rb +82 -0
  114. data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
  115. data/test/authlete/model/request/test_user-info-request.rb +75 -0
  116. data/test/authlete/model/response/test_access-token.rb +101 -0
  117. data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
  118. data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
  119. data/test/authlete/model/response/test_authorization-response.rb +145 -0
  120. data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
  121. data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
  122. data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
  123. data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
  124. data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
  125. data/test/authlete/model/response/test_client-list-response.rb +79 -0
  126. data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
  127. data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
  128. data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
  129. data/test/authlete/model/response/test_device-complete-response.rb +64 -0
  130. data/test/authlete/model/response/test_device-verification-response.rb +112 -0
  131. data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
  132. data/test/authlete/model/response/test_introspection-response.rb +127 -0
  133. data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
  134. data/test/authlete/model/response/test_revocation-response.rb +68 -0
  135. data/test/authlete/model/response/test_service-list-response.rb +72 -0
  136. data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
  137. data/test/authlete/model/response/test_token-create-response.rb +107 -0
  138. data/test/authlete/model/response/test_token-fail-response.rb +68 -0
  139. data/test/authlete/model/response/test_token-issue-response.rb +127 -0
  140. data/test/authlete/model/response/test_token-list-response.rb +84 -0
  141. data/test/authlete/model/response/test_token-response.rb +147 -0
  142. data/test/authlete/model/response/test_token-update-response.rb +87 -0
  143. data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
  144. data/test/authlete/model/response/test_user-info-response.rb +107 -0
  145. data/test/authlete/model/test_client-extension.rb +95 -0
  146. data/test/authlete/model/test_client.rb +461 -0
  147. data/test/authlete/model/test_named-uri.rb +85 -0
  148. data/test/authlete/model/test_pair.rb +85 -0
  149. data/test/authlete/model/test_property.rb +90 -0
  150. data/test/authlete/model/test_result.rb +68 -0
  151. data/test/authlete/model/test_scope.rb +106 -0
  152. data/test/authlete/model/test_service-owner.rb +80 -0
  153. data/test/authlete/model/test_service.rb +614 -0
  154. data/test/authlete/model/test_sns-credentials.rb +88 -0
  155. data/test/authlete/model/test_tagged-value.rb +83 -0
  156. data/test/authlete/test_exception.rb +70 -0
  157. metadata +173 -13
  158. data/lib/authlete/model/client-list.rb +0 -129
  159. data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
  160. data/lib/authlete/model/response/service-creatable-response.rb +0 -51
  161. data/lib/authlete/model/service-list.rb +0 -128
@@ -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.
@@ -15,42 +15,47 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
+ require 'json'
19
+
20
+
18
21
  module Authlete
19
22
  module Model
20
23
  module Response
21
- # == Authlete::Model::Response::DeveloperAuthenticationCallbackResponse class
22
- #
23
- # This class represents a response from a developer authentication callback endpoint.
24
- class DeveloperAuthenticationCallbackResponse
24
+ class DeveloperAuthenticationCallbackResponse < Authlete::Model::Base
25
25
  include Authlete::Utility
26
- # True when the developer has been authenticated (= is a valid developer).
26
+
27
27
  attr_accessor :authenticated
28
28
 
29
- # The unique identifier of the developer.
30
29
  attr_accessor :subject
31
30
 
32
- # The display name of the developer.
33
31
  attr_accessor :displayName
34
32
  alias_method :display_name, :displayName
35
33
  alias_method :display_name=, :displayName=
36
34
 
37
- # The constructor which takes a hash that represents a JSON response
38
- # from a developer authentication callback endpoint.
39
- def initialize(hash = {})
40
- @authenticated = extract_boolean_value(hash, :authenticated)
41
- @subject = extract_value(hash, :subject)
42
- @displayName = extract_value(hash, :displayName)
35
+ private
36
+
37
+ def defaults
38
+ {
39
+ authenticated: false,
40
+ subject: nil,
41
+ displayName: nil
42
+ }
43
+ end
44
+
45
+ def set_params(hash)
46
+ @authenticated = hash[:authenticated]
47
+ @subject = hash[:subject]
48
+ @displayName = hash[:displayName]
43
49
  end
44
50
 
45
- # Generate an array which is usable as a Rack response from this instance.
46
51
  def to_rack_response
47
52
  to_rack_response_json(200, JSON.generate(
48
- :authenticated => @authenticated,
49
- :subject => @subject,
50
- :displayName => @displayName
53
+ authenticated: @authenticated,
54
+ subject: @subject,
55
+ displayNam: @displayName
51
56
  ))
52
57
  end
53
58
  end
54
59
  end
55
60
  end
56
- end
61
+ end
@@ -0,0 +1,134 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ module Authlete
19
+ module Model
20
+ module Response
21
+ class DeviceAuthorizationResponse < Authlete::Model::Result
22
+ include Authlete::Utility
23
+
24
+ attr_accessor :action
25
+
26
+ attr_accessor :responseContent
27
+ alias_method :response_content, :responseContent
28
+ alias_method :response_content=, :responseContent=
29
+
30
+ attr_accessor :clientId
31
+ alias_method :client_id, :clientId
32
+ alias_method :client_id=, :clientId=
33
+
34
+ attr_accessor :clientIdAlias
35
+ alias_method :client_id_alias, :clientIdAlias
36
+ alias_method :client_id_alias=, :clientIdAlias=
37
+
38
+ attr_accessor :clientIdAliasUsed
39
+ alias_method :client_id_alias_used, :clientIdAliasUsed
40
+ alias_method :client_id_alias_used=, :clientIdAliasUsed=
41
+
42
+ attr_accessor :clientName
43
+ alias_method :client_name, :clientName
44
+ alias_method :client_name=, :clientName=
45
+
46
+ attr_accessor :clientAuthMethod
47
+ alias_method :client_auth_method, :clientAuthMethod
48
+ alias_method :client_auth_method=, :clientAuthMethod=
49
+
50
+ attr_accessor :scopes
51
+
52
+ attr_accessor :clientNames
53
+ alias_method :client_names, :clientNames
54
+ alias_method :client_names=, :clientNames=
55
+
56
+ attr_accessor :acrs
57
+
58
+ attr_accessor :deviceCode
59
+ alias_method :device_code, :deviceCode
60
+ alias_method :device_code=, :deviceCode=
61
+
62
+ attr_accessor :userCode
63
+ alias_method :user_code, :userCode
64
+ alias_method :user_code=, :userCode=
65
+
66
+ attr_accessor :verificationUri
67
+ alias_method :verification_uri, :verificationUri
68
+ alias_method :verification_uri=, :verificationUri=
69
+
70
+ attr_accessor :verificationUriComplete
71
+ alias_method :verification_uri_complete, :verificationUriComplete
72
+ alias_method :verification_uri_complete=, :verificationUriComplete=
73
+
74
+ attr_accessor :expiresIn
75
+ alias_method :expires_in, :expiresIn
76
+ alias_method :expires_in=, :expiresIn=
77
+
78
+ attr_accessor :interval
79
+
80
+ attr_accessor :resources
81
+
82
+ attr_accessor :warnings
83
+
84
+ private
85
+
86
+ def defaults
87
+ super.merge(
88
+ action: nil,
89
+ responseContent: nil,
90
+ clientId: 0,
91
+ clientIdAlias: nil,
92
+ clientIdAliasUsed: false,
93
+ clientName: nil,
94
+ clientAuthMethod: nil,
95
+ scopes: nil,
96
+ clientNames: nil,
97
+ acrs: nil,
98
+ deviceCode: nil,
99
+ userCode: nil,
100
+ verificationUri: nil,
101
+ verificationUriComplete: nil,
102
+ expiresIn: 0,
103
+ interval: 0,
104
+ resources: nil,
105
+ warnings: nil
106
+ )
107
+ end
108
+
109
+ def set_params(hash)
110
+ super(hash)
111
+
112
+ @action = hash[:action]
113
+ @responseContent = hash[:responseContent]
114
+ @clientId = hash[:clientId]
115
+ @clientIdAlias = hash[:clientIdAlias]
116
+ @clientIdAliasUsed = hash[:clientIdAliasUsed]
117
+ @clientName = hash[:clientName]
118
+ @clientAuthMethod = hash[:clientAuthMethod]
119
+ @scopes = get_parsed_array(hash[:scopes]) { |e| Authlete::Model::Scope.parse(e) }
120
+ @clientNames = hash[:clientNames]
121
+ @acrs = hash[:acrs]
122
+ @deviceCode = hash[:deviceCode]
123
+ @userCode = hash[:userCode]
124
+ @verificationUri = hash[:verificationUri]
125
+ @verificationUriComplete = hash[:verificationUriComplete]
126
+ @expiresIn = hash[:expiresIn]
127
+ @interval = hash[:interval]
128
+ @resources = hash[:resources]
129
+ @warnings = hash[:warnings]
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,39 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ module Authlete
19
+ module Model
20
+ module Response
21
+ class DeviceCompleteResponse < Authlete::Model::Result
22
+
23
+ attr_accessor :action
24
+
25
+ private
26
+
27
+ def defaults
28
+ super.merge(action: nil)
29
+ end
30
+
31
+ def set_params(hash)
32
+ super(hash)
33
+
34
+ @action = hash[:action]
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,96 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ module Authlete
19
+ module Model
20
+ module Response
21
+ class DeviceVerificationResponse < Authlete::Model::Result
22
+ include Authlete::Utility
23
+
24
+ attr_accessor :action
25
+
26
+ attr_accessor :responseContent
27
+ alias_method :response_content, :responseContent
28
+ alias_method :response_content=, :responseContent=
29
+
30
+ attr_accessor :clientId
31
+ alias_method :client_id, :clientId
32
+ alias_method :client_id=, :clientId=
33
+
34
+ attr_accessor :clientIdAlias
35
+ alias_method :client_id_alias, :clientIdAlias
36
+ alias_method :client_id_alias=, :clientIdAlias=
37
+
38
+ attr_accessor :clientIdAliasUsed
39
+ alias_method :client_id_alias_used, :clientIdAliasUsed
40
+ alias_method :client_id_alias_used=, :clientIdAliasUsed=
41
+
42
+ attr_accessor :clientName
43
+ alias_method :client_name, :clientName
44
+ alias_method :client_name=, :clientName=
45
+
46
+ attr_accessor :scopes
47
+
48
+ attr_accessor :clientNames
49
+ alias_method :client_names, :clientNames
50
+ alias_method :client_names=, :clientNames=
51
+
52
+ attr_accessor :acrs
53
+
54
+ attr_accessor :expiresAt
55
+ alias_method :expires_at, :expiresAt
56
+ alias_method :expires_at=, :expiresAt=
57
+
58
+ attr_accessor :resources
59
+
60
+ private
61
+
62
+ def defaults
63
+ super.merge(
64
+ action: nil,
65
+ responseContent: nil,
66
+ clientId: 0,
67
+ clientIdAlias: nil,
68
+ clientIdAliasUsed: false,
69
+ clientName: nil,
70
+ scopes: nil,
71
+ clientNames: nil,
72
+ acrs: nil,
73
+ expiresAt: 0,
74
+ resources: nil
75
+ )
76
+ end
77
+
78
+ def set_params(hash)
79
+ super(hash)
80
+
81
+ @action = hash[:action]
82
+ @responseContent = hash[:responseContent]
83
+ @clientId = hash[:clientId]
84
+ @clientIdAlias = hash[:clientIdAlias]
85
+ @clientIdAliasUsed = hash[:clientIdAliasUsed]
86
+ @clientName = hash[:clientName]
87
+ @scopes = get_parsed_array(hash[:scopes]) { |e| Authlete::Model::Scope.parse(e) }
88
+ @clientNames = hash[:clientNames]
89
+ @acrs = hash[:acrs]
90
+ @expiresAt = hash[:expiresAt]
91
+ @resources = hash[:resources]
92
+ end
93
+ end
94
+ end
95
+ end
96
+ 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.
@@ -18,46 +18,54 @@
18
18
  module Authlete
19
19
  module Model
20
20
  module Response
21
- # == Authlete::Model::Response::GrantedScopesGetResponse class
22
- #
23
- # A class that represents a response from Authlete's
24
- # /api/client/granted_scopes/get/{clientId} API.
25
21
  class GrantedScopesGetResponse < Authlete::Model::Result
26
- # Service API key. (Integer)
22
+
27
23
  attr_accessor :serviceApiKey
28
24
  alias_method :service_api_key, :serviceApiKey
29
25
  alias_method :service_api_key=, :serviceApiKey=
30
26
 
31
- # Client ID.. (Integer)
32
27
  attr_accessor :clientId
33
28
  alias_method :client_id, :clientId
34
29
  alias_method :client_id=, :clientId=
35
30
 
36
- # Unique User ID. (String)
37
31
  attr_accessor :subject
38
32
 
39
- # Scopes granted by the last authorization process. (String array)
40
33
  attr_accessor :latestGrantedScopes
41
34
  alias_method :latest_granted_scopes, :latestGrantedScopes
42
35
  alias_method :latest_granted_scopes=, :latestGrantedScopes=
43
36
 
44
- # All scopes granted so far. (String array)
45
37
  attr_accessor :mergedGrantedScopes
46
38
  alias_method :merged_granted_scopes, :mergedGrantedScopes
47
39
  alias_method :merged_granted_scopes=, :mergedGrantedScopes=
48
40
 
49
- # The constructor which takes a hash that represents a JSON response
50
- # from /api/client/granted_scopes/get/{clientId} API.
51
- def initialize(hash = {})
41
+ attr_accessor :modifiedAt
42
+ alias_method :modified_at, :modifiedAt
43
+ alias_method :modified_at=, :modifiedAt=
44
+
45
+ private
46
+
47
+ def defaults
48
+ super.merge(
49
+ serviceApiKey: nil,
50
+ clientId: 0,
51
+ subject: nil,
52
+ latestGrantedScopes: nil,
53
+ mergedGrantedScopes: nil,
54
+ modifiedAt: 0
55
+ )
56
+ end
57
+
58
+ def set_params(hash)
52
59
  super(hash)
53
60
 
54
- @serviceApiKey = extract_integer_value(hash, :serviceApiKey)
55
- @clientId = extract_integer_value(hash, :clientId)
56
- @subject = extract_value(hash, :subject)
57
- @latestGrantedScopes = extract_value(hash, :latestGrantedScopes)
58
- @mergedGrantedScopes = extract_value(hash, :mergedGrantedScopes)
61
+ @serviceApiKey = hash[:serviceApiKey]
62
+ @clientId = hash[:clientId]
63
+ @subject = hash[:subject]
64
+ @latestGrantedScopes = hash[:latestGrantedScopes]
65
+ @mergedGrantedScopes = hash[:mergedGrantedScopes]
66
+ @modifiedAt = hash[:modifiedAt]
59
67
  end
60
68
  end
61
69
  end
62
70
  end
63
- end
71
+ 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.
@@ -18,102 +18,108 @@
18
18
  module Authlete
19
19
  module Model
20
20
  module Response
21
- # == Authlete::Model::Response::IntrospectionResponse class
22
- #
23
- # A class that represents a response from Authlete's
24
- # /api/auth/introspection API.
25
21
  class IntrospectionResponse < Authlete::Model::Result
26
- # The next action which the caller of the API should take next.
27
- # (String)
22
+ include Authlete::Utility
23
+
28
24
  attr_accessor :action
29
25
 
30
- # The ID of the client application which is associated with
31
- # the access token. (Integer)
32
26
  attr_accessor :clientId
33
27
  alias_method :client_id, :clientId
34
28
  alias_method :client_id=, :clientId=
35
29
 
36
- # The flag which indicates whether the client ID alias was used when
37
- # the authorization request for the access token was made. (String)
38
30
  attr_accessor :clientIdAlias
39
31
  alias_method :client_id_alias, :clientIdAlias
40
32
  alias_method :client_id_alias=, :clientIdAlias=
41
33
 
42
- # The flag which indicates whether the client ID alias was used when
43
- # the authorization request or the token request for the access token
44
- # was made. (Boolean)
45
34
  attr_accessor :clientIdAliasUsed
46
35
  alias_method :client_id_alias_used, :clientIdAliasUsed
47
36
  alias_method :client_id_alias_used=, :clientIdAliasUsed=
48
37
 
49
- # The time at which the access token expires. (Integer)
50
38
  attr_accessor :expiresAt
51
39
  alias_method :expires_at, :expiresAt
52
40
  alias_method :expires_at=, :expiresAt=
53
41
 
54
- # The subject which is associated with the access token.
55
- # This is <tt>nil</tt> if the access token was created
56
- # through {Client Credentials Flow}[https://tools.ietf.org/html/rfc6749#section-4.4].
57
- # (String)
58
42
  attr_accessor :subject
59
43
 
60
- # The scopes which is associated with the access token. (String array)
61
44
  attr_accessor :scopes
62
45
 
63
- # True when the access token exists. (Boolean)
64
46
  attr_accessor :existent
47
+ alias_method :existent?, :existent
48
+ alias_method :exists, :existent
49
+ alias_method :exists?, :existent
50
+ alias_method :exist, :existent
51
+ alias_method :exist?, :existent
65
52
 
66
- # True when the access token is usable (= exists and has not expired).
67
- # (Boolean)
68
53
  attr_accessor :usable
54
+ alias_method :usable?, :usable
69
55
 
70
- # True when the access token covers all the scopes (if specified).
71
- # (Boolean)
72
56
  attr_accessor :sufficient
57
+ alias_method :sufficient?, :sufficient
73
58
 
74
- # True when the access token can be refreshed using its corresponding
75
- # refresh token. (Boolean)
76
59
  attr_accessor :refreshable
60
+ alias_method :refreshable?, :refreshable
77
61
 
78
- # The content of the error response that the service implementation
79
- # should return to the client application. (String)
80
- attr_accessor :response_content
62
+ attr_accessor :responseContent
81
63
  alias_method :response_content, :responseContent
82
64
  alias_method :response_content=, :responseContent=
83
65
 
84
- # Extra properties associated with the access token. (Property array)
85
66
  attr_accessor :properties
86
67
 
87
- # The constructor which takes a hash that represents a JSON response
88
- # from /api/auth/introspection API.
89
- def initialize(hash = {})
68
+ attr_accessor :certificateThumbprint
69
+ alias_method :certificate_thumbprint, :certificateThumbprint
70
+ alias_method :certificate_thumbprint=, :certificateThumbprint=
71
+
72
+ attr_accessor :resources
73
+
74
+ attr_accessor :accessTokenResources
75
+ alias_method :access_token_resources, :accessTokenResources
76
+ alias_method :access_token_resources=, :accessTokenResources=
77
+
78
+ private
79
+
80
+ def defaults
81
+ super.merge(
82
+ action: nil,
83
+ clientId: 0,
84
+ clientIdAlias: nil,
85
+ clientIdAliasUsed: false,
86
+ expiresAt: 0,
87
+ subject: nil,
88
+ scopes: nil,
89
+ existent: false,
90
+ usable: false,
91
+ sufficient: false,
92
+ refreshable: false,
93
+ responseContent: nil,
94
+ properties: nil,
95
+ certificateThumbprint: nil,
96
+ resources: nil,
97
+ accessTokenResources: nil
98
+ )
99
+ end
100
+
101
+ def set_params(hash)
90
102
  super(hash)
91
103
 
92
- @action = extract_value(hash, :action)
93
- @clientId = extract_value(hash, :clientId)
94
- @clientIdAlias = extract_value(hash, :clientIdAlias)
95
- @clientIdAliasUsed = extract_boolean_value(hash, :clientIdAliasUsed)
96
- @expiresAt = extract_integer_value(hash, :expiresAt)
97
- @subject = extract_value(hash, :subject)
98
- @scopes = extract_value(hash, :scopes)
99
- @existent = extract_boolean_value(hash, :existent)
100
- @usable = extract_boolean_value(hash, :usable)
101
- @sufficient = extract_boolean_value(hash, :sufficient)
102
- @refreshable = extract_boolean_value(hash, :refreshable)
103
- @responseContent = extract_value(hash, :responseContent)
104
- @properties = extract_array_value(hash, :scopes) do |element|
105
- Authlete::Model::Property.parse(element)
106
- end
104
+ @action = hash[:action]
105
+ @clientId = hash[:clientId]
106
+ @clientIdAlias = hash[:clientIdAlias]
107
+ @clientIdAliasUsed = hash[:clientIdAliasUsed]
108
+ @expiresAt = hash[:expiresAt]
109
+ @subject = hash[:subject]
110
+ @scopes = hash[:scopes]
111
+ @existent = hash[:existent]
112
+ @usable = hash[:usable]
113
+ @sufficient = hash[:sufficient]
114
+ @refreshable = hash[:refreshable]
115
+ @responseContent = hash[:responseContent]
116
+ @properties = get_parsed_array(hash[:properties]) { |e| Authlete::Model::Property.parse(e) }
117
+ @certificateThumbprint = hash[:certificateThumbprint]
118
+ @resources = hash[:resources]
119
+ @accessTokenResources = hash[:accessTokenResources]
107
120
  end
108
121
 
109
- alias_method :existent?, :existent
110
- alias_method :exists, :existent
111
- alias_method :exists?, :existent
112
- alias_method :exist, :existent
113
- alias_method :exist?, :existent
114
- alias_method :usable?, :usable
115
- alias_method :sufficient?, :sufficient
116
- alias_method :refreshable?, :refreshable
122
+ public
117
123
 
118
124
  # Generate an array which is usable as a Rack response from this instance.
119
125
  # When <tt>action</tt> method returns other value than 'OK', the array
@@ -161,4 +167,4 @@ module Authlete
161
167
  end
162
168
  end
163
169
  end
164
- end
170
+ end