authlete 0.5.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,118 @@
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::ClientAuthorizationUpdateRequest class
25
+ #
26
+ # This class represents a request to Authlete's /api/client/authorization/update API.
27
+ class ClientAuthorizationUpdateRequest < Authlete::Model::Hashable
28
+
29
+ # Unique user ID. (String)
30
+ attr_accessor :subject
31
+
32
+ # The new value of scopes that is set to existing access tokens.
33
+ # "nil" means that scopes are not changed. (String array)
34
+ attr_accessor :scopes
35
+
36
+ private
37
+
38
+ # String attributes.
39
+ STRING_ATTRIBUTES = ::Set.new([ :subject ])
40
+
41
+ # String array attributes.
42
+ STRING_ARRAY_ATTRIBUTES = ::Set.new([ :scopes ])
43
+
44
+ # The constructor which takes a hash that represents a JSON request
45
+ # to Authlete's /api/client/authorization/update API.
46
+ def initialize(hash = nil)
47
+ # Set default values to string attributes.
48
+ STRING_ATTRIBUTES.each do |attr|
49
+ send("#{attr}=", nil)
50
+ end
51
+
52
+ # Set default values to string array attributes.
53
+ STRING_ARRAY_ATTRIBUTES.each do |attr|
54
+ send("#{attr}=", nil)
55
+ end
56
+
57
+ # Set attribute values using the given hash.
58
+ authlete_model_update(hash)
59
+ end
60
+
61
+ def authlete_model_convert_key(key)
62
+ key.to_sym
63
+ end
64
+
65
+ def authlete_model_simple_attribute?(key)
66
+ STRING_ATTRIBUTES.include?(key) or
67
+ STRING_ARRAY_ATTRIBUTES.include?(key)
68
+ end
69
+
70
+ def authlete_model_update(hash)
71
+ return if hash.nil?
72
+
73
+ hash.each do |key, value|
74
+ key = authlete_model_convert_key(key)
75
+
76
+ if authlete_model_simple_attribute?(key)
77
+ send("#{key}=", value)
78
+ end
79
+ end
80
+
81
+ self
82
+ end
83
+
84
+ public
85
+
86
+ # Construct an instance from the given hash.
87
+ #
88
+ # If the given argument is nil or is not a Hash, nil is returned.
89
+ # Otherwise, ClientAuthorizationUpdateRequest.new(hash) is returned.
90
+ def self.parse(hash)
91
+ if hash.nil? or (hash.kind_of?(Hash) == false)
92
+ return nil
93
+ end
94
+
95
+ return ClientAuthorizationUpdateRequest.new(hash)
96
+ end
97
+
98
+ # Convert this object into a hash.
99
+ def to_hash
100
+ hash = {}
101
+
102
+ instance_variables.each do |var|
103
+ key = var.to_s.delete("@").to_sym
104
+ val = instance_variable_get(var)
105
+
106
+ if authlete_model_simple_attribute?(key) or val.nil?
107
+ hash[key] = val
108
+ elsif val.kind_of?(Array)
109
+ hash[key] = val.map { |element| element.to_hash }
110
+ end
111
+ end
112
+
113
+ hash
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,121 @@
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::ClientSecretUpdateRequest class
25
+ #
26
+ # This class represents a request to Authlete's /api/client/secret/update/{clientIdentifier} API.
27
+ class ClientSecretUpdateRequest < Authlete::Model::Hashable
28
+
29
+ # Client secret. (String)
30
+ #
31
+ # The new value of the client secret. Valid characters for a client
32
+ # secret are A-Z, a-z, 0-9, -, and _. The maximum length of a client
33
+ # secret is 86.
34
+ attr_accessor :clientSecret
35
+ alias_method :client_secret, :clientSecret
36
+ alias_method :client_secret=, :clientSecret=
37
+
38
+ private
39
+
40
+ # String attributes.
41
+ STRING_ATTRIBUTES = ::Set.new([ :clientSecret ])
42
+
43
+ # Mapping from snake cases to camel cases.
44
+ SNAKE_TO_CAMEL = {
45
+ :client_secret => :clientSecret
46
+ }
47
+
48
+ # The constructor which takes a hash that represents a JSON request
49
+ # to Authlete's /api/client/secret/update/{clientIdentifier} API.
50
+ def initialize(hash = nil)
51
+ # Set default values to string attributes.
52
+ STRING_ATTRIBUTES.each do |attr|
53
+ send("#{attr}=", nil)
54
+ end
55
+
56
+ # Set attribute values using the given hash.
57
+ authlete_model_update(hash)
58
+ end
59
+
60
+ def authlete_model_convert_key(key)
61
+ key = key.to_sym
62
+
63
+ # Convert snakecase to camelcase, if necessary.
64
+ if SNAKE_TO_CAMEL.has_key?(key)
65
+ key = SNAKE_TO_CAMEL[key]
66
+ end
67
+
68
+ key
69
+ end
70
+
71
+ def authlete_model_simple_attribute?(key)
72
+ STRING_ATTRIBUTES.include?(key)
73
+ end
74
+
75
+ def authlete_model_update(hash)
76
+ return if hash.nil?
77
+
78
+ hash.each do |key, value|
79
+ key = authlete_model_convert_key(key)
80
+
81
+ if authlete_model_simple_attribute?(key)
82
+ send("#{key}=", value)
83
+ end
84
+ end
85
+
86
+ self
87
+ end
88
+
89
+ public
90
+
91
+ # Construct an instance from the given hash.
92
+ #
93
+ # If the given argument is nil or is not a Hash, nil is returned.
94
+ # Otherwise, ClientSecretUpdateRequest.new(hash) is returned.
95
+ def self.parse(hash)
96
+ if hash.nil? or (hash.kind_of?(Hash) == false)
97
+ return nil
98
+ end
99
+
100
+ return ClientSecretUpdateRequest.new(hash)
101
+ end
102
+
103
+ # Convert this object into a hash.
104
+ def to_hash
105
+ hash = {}
106
+
107
+ instance_variables.each do |var|
108
+ key = var.to_s.delete("@").to_sym
109
+ val = instance_variable_get(var)
110
+
111
+ if authlete_model_simple_attribute?(key) or val.nil?
112
+ hash[key] = val
113
+ end
114
+ end
115
+
116
+ hash
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -1,85 +1,85 @@
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
- require 'json'
19
-
20
-
21
- module Authlete
22
- module Model
23
- module Request
24
- # == Authlete::Model::Request::DeveloperAuthenticationCallbackRequest class
25
- #
26
- # This class represents a request to a developer authentication callback endpoint.
27
- class DeveloperAuthenticationCallbackRequest
28
- include Authlete::Utility
29
- # The API key of the service.
30
- attr_accessor :service_api_key
31
-
32
- # The login ID that the developer input to the login ID field.
33
- # When 'sns' attribute is not nil, this attribute holds the
34
- # subject (= unique identifier) of the developer in the SNS.
35
- attr_accessor :id
36
-
37
- # The password that the developer input to the password field.
38
- # If 'sns' property is nil, it is ensured that this attribute
39
- # is not nil. In such a case, authentication should be performed
40
- # on the pair of 'id' attribute and this 'password' attribute.
41
- # On the other hand, if 'sns' attribute is not nil, this attribute
42
- # has no meaning, because authentication has performed by the SNS.
43
- attr_accessor :password
44
-
45
- # The SNS which the developer used for social login.
46
- # For example, 'FACEBOOK'.
47
- attr_accessor :sns
48
-
49
- # The access token issued at the token endpoint of the SNS.
50
- attr_accessor :access_token
51
-
52
- # The refresh token issued along with the access token.
53
- attr_accessor :refresh_token
54
-
55
- # The duration of the access token.
56
- attr_accessor :expires_in
57
-
58
- # The raw content of the response from the token endpoint of the SNS.
59
- # Correct OAuth 2.0 implementations return 'application/json', but
60
- # Facebook returns 'application/x-www-form-url-encoded'.
61
- attr_accessor :raw_token_response
62
-
63
- # The constructor which takes a hash that represents a JSON request
64
- # to a developer authentication callback endpoint.
65
- def initialize(hash = {})
66
- @service_api_key = extract_value(hash, :serviceApiKey)
67
- @id = extract_value(hash, :id)
68
- @password = extract_value(hash, :password)
69
- @sns = extract_value(hash, :sns)
70
- @access_token = extract_value(hash, :accessToken)
71
- @refresh_token = extract_value(hash, :refreshToken)
72
- @expires_in = extract_integer_value(hash, :expiresIn)
73
- @raw_token_response = extract_value(hash, :rawTokenResponse)
74
- end
75
-
76
- # Parse a JSON string which represents a request to a developer
77
- # authentication callback endpoint and generate an instance of
78
- # DeveloperAuthenticationCallbackRequest.
79
- def self.parse(json)
80
- DeveloperAuthenticationCallbackRequest.new(JSON.parse(json))
81
- end
82
- end
83
- end
84
- 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 'json'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ module Request
24
+ # == Authlete::Model::Request::DeveloperAuthenticationCallbackRequest class
25
+ #
26
+ # This class represents a request to a developer authentication callback endpoint.
27
+ class DeveloperAuthenticationCallbackRequest
28
+ include Authlete::Utility
29
+ # The API key of the service.
30
+ attr_accessor :service_api_key
31
+
32
+ # The login ID that the developer input to the login ID field.
33
+ # When 'sns' attribute is not nil, this attribute holds the
34
+ # subject (= unique identifier) of the developer in the SNS.
35
+ attr_accessor :id
36
+
37
+ # The password that the developer input to the password field.
38
+ # If 'sns' property is nil, it is ensured that this attribute
39
+ # is not nil. In such a case, authentication should be performed
40
+ # on the pair of 'id' attribute and this 'password' attribute.
41
+ # On the other hand, if 'sns' attribute is not nil, this attribute
42
+ # has no meaning, because authentication has performed by the SNS.
43
+ attr_accessor :password
44
+
45
+ # The SNS which the developer used for social login.
46
+ # For example, 'FACEBOOK'.
47
+ attr_accessor :sns
48
+
49
+ # The access token issued at the token endpoint of the SNS.
50
+ attr_accessor :access_token
51
+
52
+ # The refresh token issued along with the access token.
53
+ attr_accessor :refresh_token
54
+
55
+ # The duration of the access token.
56
+ attr_accessor :expires_in
57
+
58
+ # The raw content of the response from the token endpoint of the SNS.
59
+ # Correct OAuth 2.0 implementations return 'application/json', but
60
+ # Facebook returns 'application/x-www-form-url-encoded'.
61
+ attr_accessor :raw_token_response
62
+
63
+ # The constructor which takes a hash that represents a JSON request
64
+ # to a developer authentication callback endpoint.
65
+ def initialize(hash = {})
66
+ @service_api_key = extract_value(hash, :serviceApiKey)
67
+ @id = extract_value(hash, :id)
68
+ @password = extract_value(hash, :password)
69
+ @sns = extract_value(hash, :sns)
70
+ @access_token = extract_value(hash, :accessToken)
71
+ @refresh_token = extract_value(hash, :refreshToken)
72
+ @expires_in = extract_integer_value(hash, :expiresIn)
73
+ @raw_token_response = extract_value(hash, :rawTokenResponse)
74
+ end
75
+
76
+ # Parse a JSON string which represents a request to a developer
77
+ # authentication callback endpoint and generate an instance of
78
+ # DeveloperAuthenticationCallbackRequest.
79
+ def self.parse(json)
80
+ DeveloperAuthenticationCallbackRequest.new(JSON.parse(json))
81
+ end
82
+ end
83
+ end
84
+ end
85
85
  end
@@ -0,0 +1,103 @@
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::GrantedScopesRequest class
25
+ #
26
+ # This class represents a request to Authlete's /api/client/granted_scopes/get/{clientId} API
27
+ # and api/client/granted_scopes/delete/{clientId} API.
28
+ class GrantedScopesRequest < Authlete::Model::Hashable
29
+ # Unique user ID. (String)
30
+ attr_accessor :subject
31
+
32
+ private
33
+
34
+ # String attributes.
35
+ STRING_ATTRIBUTES = ::Set.new([ :subject ])
36
+
37
+ # The constructor which takes a hash that represents a JSON request to
38
+ # Authlete's /api/auth/token/create API.
39
+ def initialize(hash = nil)
40
+ # Set default values to string attributes.
41
+ STRING_ATTRIBUTES.each do |attr|
42
+ send("#{attr}=", nil)
43
+ end
44
+
45
+ # Set attribute values using the given hash.
46
+ authlete_model_update(hash)
47
+ end
48
+
49
+ def authlete_model_convert_key(key)
50
+ key.to_sym
51
+ end
52
+
53
+ def authlete_model_simple_attribute?(key)
54
+ STRING_ATTRIBUTES.include?(key)
55
+ end
56
+
57
+ def authlete_model_update(hash)
58
+ return if hash.nil?
59
+
60
+ hash.each do |key, value|
61
+ key = authlete_model_convert_key(key)
62
+
63
+ if authlete_model_simple_attribute?(key)
64
+ send("#{key}=", value)
65
+ end
66
+ end
67
+
68
+ self
69
+ end
70
+
71
+ public
72
+
73
+ # Construct an instance from the given hash.
74
+ #
75
+ # If the given argument is nil or is not a Hash, nil is returned.
76
+ # Otherwise, GrantedScopesRequest.new(hash) is returned.
77
+ def self.parse(hash)
78
+ if hash.nil? or (hash.kind_of?(Hash) == false)
79
+ return nil
80
+ end
81
+
82
+ return GrantedScopesRequest.new(hash)
83
+ end
84
+
85
+ # Convert this object into a hash.
86
+ def to_hash
87
+ hash = {}
88
+
89
+ instance_variables.each do |var|
90
+ key = var.to_s.delete("@").to_sym
91
+ val = instance_variable_get(var)
92
+
93
+ if authlete_model_simple_attribute?(key) or val.nil?
94
+ hash[key] = val
95
+ end
96
+ end
97
+
98
+ hash
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end