authlete 0.5.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/authlete.rb +24 -1
  3. data/lib/authlete/api.rb +298 -146
  4. data/lib/authlete/authentication-server.rb +1 -1
  5. data/lib/authlete/exception.rb +6 -3
  6. data/lib/authlete/model/client-extension.rb +135 -135
  7. data/lib/authlete/model/client-list.rb +128 -128
  8. data/lib/authlete/model/client.rb +468 -468
  9. data/lib/authlete/model/hashable.rb +1 -1
  10. data/lib/authlete/model/pair.rb +102 -102
  11. data/lib/authlete/model/property.rb +116 -0
  12. data/lib/authlete/model/request/authentication-callback-request.rb +90 -90
  13. data/lib/authlete/model/request/authorization-fail-request.rb +107 -104
  14. data/lib/authlete/model/request/authorization-issue-request.rb +167 -133
  15. data/lib/authlete/model/request/authorization-request.rb +101 -101
  16. data/lib/authlete/model/request/client-authorization-delete-request.rb +123 -0
  17. data/lib/authlete/model/request/client-authorization-get-list-request.rb +123 -0
  18. data/lib/authlete/model/request/client-authorization-update-request.rb +118 -0
  19. data/lib/authlete/model/request/client-secret-update-request.rb +121 -0
  20. data/lib/authlete/model/request/developer-authentication-callback-request.rb +84 -84
  21. data/lib/authlete/model/request/granted-scopes-request.rb +103 -0
  22. data/lib/authlete/model/request/introspection-request.rb +117 -39
  23. data/lib/authlete/model/request/revocation-request.rb +125 -0
  24. data/lib/authlete/model/request/standard-introspection-request.rb +102 -0
  25. data/lib/authlete/model/request/token-create-request.rb +250 -0
  26. data/lib/authlete/model/request/token-fail-request.rb +104 -101
  27. data/lib/authlete/model/request/token-issue-request.rb +116 -101
  28. data/lib/authlete/model/request/token-request.rb +127 -121
  29. data/lib/authlete/model/request/token-update-request.rb +165 -0
  30. data/lib/authlete/model/request/user-info-issue-request.rb +113 -0
  31. data/lib/authlete/model/request/user-info-request.rb +102 -0
  32. data/lib/authlete/model/response/authentication-callback-response.rb +53 -53
  33. data/lib/authlete/model/response/authorization-fail-response.rb +48 -48
  34. data/lib/authlete/model/response/authorization-issue-response.rb +85 -48
  35. data/lib/authlete/model/response/authorization-response.rb +177 -164
  36. data/lib/authlete/model/response/client-authorization-get-list-response.rb +60 -0
  37. data/lib/authlete/model/response/client-secret-refresh-response.rb +48 -0
  38. data/lib/authlete/model/response/client-secret-update-response.rb +48 -0
  39. data/lib/authlete/model/response/developer-authentication-callback-response.rb +55 -55
  40. data/lib/authlete/model/response/granted-scopes-get-response.rb +63 -0
  41. data/lib/authlete/model/response/introspection-response.rb +163 -132
  42. data/lib/authlete/model/response/revocation-response.rb +49 -0
  43. data/lib/authlete/model/response/service-creatable-response.rb +50 -50
  44. data/lib/authlete/model/response/standard-introspection-response.rb +49 -0
  45. data/lib/authlete/model/response/token-create-response.rb +100 -0
  46. data/lib/authlete/model/response/token-fail-response.rb +49 -49
  47. data/lib/authlete/model/response/token-issue-response.rb +138 -49
  48. data/lib/authlete/model/response/token-response.rb +168 -70
  49. data/lib/authlete/model/response/token-update-response.rb +62 -0
  50. data/lib/authlete/model/response/user-info-issue-response.rb +47 -0
  51. data/lib/authlete/model/response/user-info-response.rb +85 -0
  52. data/lib/authlete/model/result.rb +44 -44
  53. data/lib/authlete/model/scope.rb +1 -1
  54. data/lib/authlete/model/service-list.rb +1 -1
  55. data/lib/authlete/model/service-owner.rb +1 -1
  56. data/lib/authlete/model/service.rb +4 -2
  57. data/lib/authlete/model/sns-credentials.rb +1 -1
  58. data/lib/authlete/model/tagged-value.rb +97 -97
  59. data/lib/authlete/utility.rb +1 -1
  60. data/lib/authlete/version.rb +2 -2
  61. metadata +24 -2
@@ -1,105 +1,108 @@
1
- # :nodoc:
2
- #
3
- # Copyright (C) 2014-2015 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 Request
21
- # == Authlete::Model::Request::AuthorizationFailRequest class
22
- #
23
- # This class represents a request to Authlete's /api/auth/authorization/fail API.
24
- class AuthorizationFailRequest < Authlete::Model::Hashable
25
- # The ticket issued by Authlete's /api/auth/authorization API. (String)
26
- attr_accessor :ticket
27
-
28
- # The reason of the failure. (String)
29
- attr_accessor :reason
30
-
31
- # The custom description about the failure. (String)
32
- attr_accessor :description
33
-
34
- private
35
-
36
- # String attributes.
37
- STRING_ATTRIBUTES = ::Set.new([ :ticket, :reason, :description ])
38
-
39
- # The constructor which takes a hash that represents a JSON request to
40
- # Authlete's /api/auth/authorization/fail API.
41
- def initialize(hash = nil)
42
- # Set default values to string attributes.
43
- STRING_ATTRIBUTES.each do |attr|
44
- send("#{attr}=", nil)
45
- end
46
-
47
- # Set attribute values using the given hash.
48
- authlete_model_update(hash)
49
- end
50
-
51
- def authlete_model_convert_key(key)
52
- key.to_sym
53
- end
54
-
55
- def authlete_model_simple_attribute?(key)
56
- STRING_ATTRIBUTES.include?(key)
57
- end
58
-
59
- def authlete_model_update(hash)
60
- return if hash.nil?
61
-
62
- hash.each do |key, value|
63
- key = authlete_model_convert_key(key)
64
-
65
- if authlete_model_simple_attribute?(key)
66
- send("#{key}=", value)
67
- end
68
- end
69
-
70
- self
71
- end
72
-
73
- public
74
-
75
- # Construct an instance from the given hash.
76
- #
77
- # If the given argument is nil or is not a Hash, nil is returned.
78
- # Otherwise, AuthorizationFailRequest.new(hash) is returned.
79
- def self.parse(hash)
80
- if hash.nil? or (hash.kind_of?(Hash) == false)
81
- return nil
82
- end
83
-
84
- return AuthorizationFailRequest.new(hash)
85
- end
86
-
87
- # Convert this object into a hash.
88
- def to_hash
89
- hash = {}
90
-
91
- instance_variables.each do |var|
92
- key = var.to_s.delete("@").to_sym
93
- val = instance_variable_get(var)
94
-
95
- if authlete_model_simple_attribute?(key) or val.nil?
96
- hash[key] = val
97
- end
98
- end
99
-
100
- hash
101
- end
102
- end
103
- end
104
- end
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2018 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
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ module Request
24
+ # == Authlete::Model::Request::AuthorizationFailRequest class
25
+ #
26
+ # This class represents a request to Authlete's /api/auth/authorization/fail API.
27
+ class AuthorizationFailRequest < Authlete::Model::Hashable
28
+ # The ticket issued by Authlete's /api/auth/authorization API. (String)
29
+ attr_accessor :ticket
30
+
31
+ # The reason of the failure. (String)
32
+ attr_accessor :reason
33
+
34
+ # The custom description about the failure. (String)
35
+ attr_accessor :description
36
+
37
+ private
38
+
39
+ # String attributes.
40
+ STRING_ATTRIBUTES = ::Set.new([ :ticket, :reason, :description ])
41
+
42
+ # The constructor which takes a hash that represents a JSON request to
43
+ # Authlete's /api/auth/authorization/fail API.
44
+ def initialize(hash = nil)
45
+ # Set default values to string attributes.
46
+ STRING_ATTRIBUTES.each do |attr|
47
+ send("#{attr}=", nil)
48
+ end
49
+
50
+ # Set attribute values using the given hash.
51
+ authlete_model_update(hash)
52
+ end
53
+
54
+ def authlete_model_convert_key(key)
55
+ key.to_sym
56
+ end
57
+
58
+ def authlete_model_simple_attribute?(key)
59
+ STRING_ATTRIBUTES.include?(key)
60
+ end
61
+
62
+ def authlete_model_update(hash)
63
+ return if hash.nil?
64
+
65
+ hash.each do |key, value|
66
+ key = authlete_model_convert_key(key)
67
+
68
+ if authlete_model_simple_attribute?(key)
69
+ send("#{key}=", value)
70
+ end
71
+ end
72
+
73
+ self
74
+ end
75
+
76
+ public
77
+
78
+ # Construct an instance from the given hash.
79
+ #
80
+ # If the given argument is nil or is not a Hash, nil is returned.
81
+ # Otherwise, AuthorizationFailRequest.new(hash) is returned.
82
+ def self.parse(hash)
83
+ if hash.nil? or (hash.kind_of?(Hash) == false)
84
+ return nil
85
+ end
86
+
87
+ return AuthorizationFailRequest.new(hash)
88
+ end
89
+
90
+ # Convert this object into a hash.
91
+ def to_hash
92
+ hash = {}
93
+
94
+ instance_variables.each do |var|
95
+ key = var.to_s.delete("@").to_sym
96
+ val = instance_variable_get(var)
97
+
98
+ if authlete_model_simple_attribute?(key) or val.nil?
99
+ hash[key] = val
100
+ end
101
+ end
102
+
103
+ hash
104
+ end
105
+ end
106
+ end
107
+ end
105
108
  end
@@ -1,134 +1,168 @@
1
- # :nodoc:
2
- #
3
- # Copyright (C) 2014-2015 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 Request
21
- # == Authlete::Model::Request::AuthorizationIssueRequest class
22
- #
23
- # This class represents a request to Authlete's /api/auth/authorization/issue API.
24
- class AuthorizationIssueRequest < Authlete::Model::Hashable
25
- # The ticket issued by Authlete's /api/auth/authorization API. (String)
26
- attr_accessor :ticket
27
-
28
- # The subject (end-user) managed by the service. (String)
29
- attr_accessor :subject
30
-
31
- # The time when the end-user was authenticated. (Integer)
32
- attr_accessor :authTime
33
- alias_method :auth_time, :authTime
34
- alias_method :auth_time=, :authTime=
35
-
36
- # The authentication context class reference. (String)
37
- attr_accessor :acr
38
-
39
- # Claims in JSON format. (String)
40
- attr_accessor :claims
41
-
42
- private
43
-
44
- # Integer attributes.
45
- INTEGER_ATTRIBUTES = ::Set.new([ :authTime ])
46
-
47
- # String attributes.
48
- STRING_ATTRIBUTES = ::Set.new([ :ticket, :subject, :acr, :claims ])
49
-
50
- # Mapping from snake cases to camel cases.
51
- SNAKE_TO_CAMEL = {
52
- :auth_time => :authTime
53
- }
54
-
55
- # The constructor which takes a hash that represents a JSON request to
56
- # Authlete's /api/auth/authorization/issue API.
57
- def initialize(hash = nil)
58
- # Set default values to integer attributes.
59
- INTEGER_ATTRIBUTES.each do |attr|
60
- send("#{attr}=", 0)
61
- end
62
-
63
- # Set default values to string attributes.
64
- STRING_ATTRIBUTES.each do |attr|
65
- send("#{attr}=", nil)
66
- end
67
-
68
- # Set attribute values using the given hash.
69
- authlete_model_update(hash)
70
- end
71
-
72
- def authlete_model_convert_key(key)
73
- key = key.to_sym
74
-
75
- # Convert snakecase to camelcase, if necessary.
76
- if SNAKE_TO_CAMEL.has_key?(key)
77
- key = SNAKE_TO_CAMEL[key]
78
- end
79
-
80
- key
81
- end
82
-
83
- def authlete_model_simple_attribute?(key)
84
- INTEGER_ATTRIBUTES.include?(key) or
85
- STRING_ATTRIBUTES.include?(key)
86
- end
87
-
88
- def authlete_model_update(hash)
89
- return if hash.nil?
90
-
91
- hash.each do |key, value|
92
- key = authlete_model_convert_key(key)
93
-
94
- if authlete_model_simple_attribute?(key)
95
- send("#{key}=", value)
96
- end
97
- end
98
-
99
- self
100
- end
101
-
102
- public
103
-
104
- # Construct an instance from the given hash.
105
- #
106
- # If the given argument is nil or is not a Hash, nil is returned.
107
- # Otherwise, AuthorizationIssueRequest.new(hash) is returned.
108
- def self.parse(hash)
109
- if hash.nil? or (hash.kind_of?(Hash) == false)
110
- return nil
111
- end
112
-
113
- return AuthorizationIssueRequest.new(hash)
114
- end
115
-
116
- # Convert this object into a hash.
117
- def to_hash
118
- hash = {}
119
-
120
- instance_variables.each do |var|
121
- key = var.to_s.delete("@").to_sym
122
- val = instance_variable_get(var)
123
-
124
- if authlete_model_simple_attribute?(key) or val.nil?
125
- hash[key] = val
126
- end
127
- end
128
-
129
- hash
130
- end
131
- end
132
- end
133
- end
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2018 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
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ module Request
24
+ # == Authlete::Model::Request::AuthorizationIssueRequest class
25
+ #
26
+ # This class represents a request to Authlete's /api/auth/authorization/issue API.
27
+ class AuthorizationIssueRequest < Authlete::Model::Hashable
28
+ # The ticket issued by Authlete's /api/auth/authorization API. (String)
29
+ attr_accessor :ticket
30
+
31
+ # The subject (end-user) managed by the service. (String)
32
+ attr_accessor :subject
33
+
34
+ # The time when the end-user was authenticated. (Integer)
35
+ attr_accessor :authTime
36
+ alias_method :auth_time, :authTime
37
+ alias_method :auth_time=, :authTime=
38
+
39
+ # The authentication context class reference. (String)
40
+ attr_accessor :acr
41
+
42
+ # Claims in JSON format. (String)
43
+ attr_accessor :claims
44
+
45
+ # Extra properties to associate with an access token and/or an
46
+ # authorization code. (String)
47
+ attr_accessor :properties
48
+
49
+ # Scopes to associate with an access token and/or an authorization code.
50
+ # If a non-empty string array is given, it replaces the scopes specified
51
+ # by the original authorization request. (String array)
52
+ attr_accessor :scopes
53
+
54
+ # The value of the "sub" claim to embed in an ID token. If this request
55
+ # parameter is "nil" or empty, the value of the subject request parameter
56
+ # is used as the value of the "sub" claim. (String)
57
+ attr_accessor :sub
58
+
59
+ private
60
+
61
+ # Integer attributes.
62
+ INTEGER_ATTRIBUTES = ::Set.new([ :authTime ])
63
+
64
+ # String attributes.
65
+ STRING_ATTRIBUTES = ::Set.new([ :ticket, :subject, :acr, :claims, :sub ])
66
+
67
+ # String array attributes.
68
+ STRING_ARRAY_ATTRIBUTES = ::Set.new([ :scopes ])
69
+
70
+ # Mapping from snake cases to camel cases.
71
+ SNAKE_TO_CAMEL = {
72
+ :auth_time => :authTime
73
+ }
74
+
75
+ # The constructor which takes a hash that represents a JSON request to
76
+ # Authlete's /api/auth/authorization/issue API.
77
+ def initialize(hash = nil)
78
+ # Set default values to integer attributes.
79
+ INTEGER_ATTRIBUTES.each do |attr|
80
+ send("#{attr}=", 0)
81
+ end
82
+
83
+ # Set default values to string attributes.
84
+ STRING_ATTRIBUTES.each do |attr|
85
+ send("#{attr}=", nil)
86
+ end
87
+
88
+ # Set default values to string array attributes.
89
+ STRING_ARRAY_ATTRIBUTES.each do |attr|
90
+ send("#{attr}=", nil)
91
+ end
92
+
93
+ @properties = nil
94
+
95
+ # Set attribute values using the given hash.
96
+ authlete_model_update(hash)
97
+ end
98
+
99
+ def authlete_model_convert_key(key)
100
+ key = key.to_sym
101
+
102
+ # Convert snakecase to camelcase, if necessary.
103
+ if SNAKE_TO_CAMEL.has_key?(key)
104
+ key = SNAKE_TO_CAMEL[key]
105
+ end
106
+
107
+ key
108
+ end
109
+
110
+ def authlete_model_simple_attribute?(key)
111
+ INTEGER_ATTRIBUTES.include?(key) or
112
+ STRING_ATTRIBUTES.include?(key) or
113
+ STRING_ARRAY_ATTRIBUTES.include?(key)
114
+ end
115
+
116
+ def authlete_model_update(hash)
117
+ return if hash.nil?
118
+
119
+ hash.each do |key, value|
120
+ key = authlete_model_convert_key(key)
121
+
122
+ if authlete_model_simple_attribute?(key)
123
+ send("#{key}=", value)
124
+ elsif key == :properties
125
+ @properties = get_parsed_array(value) do |element|
126
+ Authlete::Model::Property.parse(element)
127
+ end
128
+ end
129
+ end
130
+
131
+ self
132
+ end
133
+
134
+ public
135
+
136
+ # Construct an instance from the given hash.
137
+ #
138
+ # If the given argument is nil or is not a Hash, nil is returned.
139
+ # Otherwise, AuthorizationIssueRequest.new(hash) is returned.
140
+ def self.parse(hash)
141
+ if hash.nil? or (hash.kind_of?(Hash) == false)
142
+ return nil
143
+ end
144
+
145
+ return AuthorizationIssueRequest.new(hash)
146
+ end
147
+
148
+ # Convert this object into a hash.
149
+ def to_hash
150
+ hash = {}
151
+
152
+ instance_variables.each do |var|
153
+ key = var.to_s.delete("@").to_sym
154
+ val = instance_variable_get(var)
155
+
156
+ if authlete_model_simple_attribute?(key) or val.nil?
157
+ hash[key] = val
158
+ elsif key == :properties
159
+ hash[key] = val.map { |element| element.to_hash }
160
+ end
161
+ end
162
+
163
+ hash
164
+ end
165
+ end
166
+ end
167
+ end
134
168
  end