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
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2015 Authlete, Inc.
3
+ # Copyright (C) 2014-2018 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.
@@ -1,103 +1,103 @@
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 'set'
19
-
20
-
21
- module Authlete
22
- module Model
23
- class Pair < Authlete::Model::Hashable
24
- include Authlete::Utility
25
- # The key of this pair. (String)
26
- attr_accessor :key
27
-
28
- # The value of this pair. (String)
29
- attr_accessor :value
30
-
31
- private
32
-
33
- # String attributes.
34
- STRING_ATTRIBUTES = ::Set.new([ :key, :value ])
35
-
36
- # The constructor
37
- def initialize(hash = nil)
38
- # Set default values to string attributes.
39
- STRING_ATTRIBUTES.each do |attr|
40
- send("#{attr}=", nil)
41
- end
42
-
43
- # Set attribute values using the given hash.
44
- authlete_model_update(hash)
45
- end
46
-
47
- def authlete_model_convert_key(key)
48
- key.to_sym
49
- end
50
-
51
- def authlete_model_simple_attribute?(key)
52
- STRING_ATTRIBUTES.include?(key)
53
- end
54
-
55
- def authlete_model_update(hash)
56
- return if hash.nil?
57
-
58
- hash.each do |key, value|
59
- key = authlete_model_convert_key(key)
60
-
61
- if authlete_model_simple_attribute?(key)
62
- send("#{key}=", value)
63
- end
64
- end
65
-
66
- self
67
- end
68
-
69
- public
70
-
71
- # Construct an instance from the given hash.
72
- #
73
- # If the given argument is nil or is not a Hash, nil is returned.
74
- # Otherwise, Scope.new(hash) is returned.
75
- def self.parse(hash)
76
- if hash.nil? or (hash.kind_of?(Hash) == false)
77
- return nil
78
- end
79
-
80
- Authlete::Model::Pair.new(hash)
81
- end
82
-
83
- # Set attribute values using the given hash.
84
- def update(hash)
85
- authlete_model_update(hash)
86
- end
87
-
88
- # Convert this object into a hash.
89
- def to_hash
90
- hash = {}
91
-
92
- instance_variables.each do |var|
93
- key = var.to_s.delete("@").to_sym
94
- val = instance_variable_get(var)
95
-
96
- hash[key] = val
97
- end
98
-
99
- hash
100
- end
101
- end
102
- 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
+ class Pair < Authlete::Model::Hashable
24
+ include Authlete::Utility
25
+ # The key of this pair. (String)
26
+ attr_accessor :key
27
+
28
+ # The value of this pair. (String)
29
+ attr_accessor :value
30
+
31
+ private
32
+
33
+ # String attributes.
34
+ STRING_ATTRIBUTES = ::Set.new([ :key, :value ])
35
+
36
+ # The constructor
37
+ def initialize(hash = nil)
38
+ # Set default values to string attributes.
39
+ STRING_ATTRIBUTES.each do |attr|
40
+ send("#{attr}=", nil)
41
+ end
42
+
43
+ # Set attribute values using the given hash.
44
+ authlete_model_update(hash)
45
+ end
46
+
47
+ def authlete_model_convert_key(key)
48
+ key.to_sym
49
+ end
50
+
51
+ def authlete_model_simple_attribute?(key)
52
+ STRING_ATTRIBUTES.include?(key)
53
+ end
54
+
55
+ def authlete_model_update(hash)
56
+ return if hash.nil?
57
+
58
+ hash.each do |key, value|
59
+ key = authlete_model_convert_key(key)
60
+
61
+ if authlete_model_simple_attribute?(key)
62
+ send("#{key}=", value)
63
+ end
64
+ end
65
+
66
+ self
67
+ end
68
+
69
+ public
70
+
71
+ # Construct an instance from the given hash.
72
+ #
73
+ # If the given argument is nil or is not a Hash, nil is returned.
74
+ # Otherwise, Pair.new(hash) is returned.
75
+ def self.parse(hash)
76
+ if hash.nil? or (hash.kind_of?(Hash) == false)
77
+ return nil
78
+ end
79
+
80
+ Authlete::Model::Pair.new(hash)
81
+ end
82
+
83
+ # Set attribute values using the given hash.
84
+ def update(hash)
85
+ authlete_model_update(hash)
86
+ end
87
+
88
+ # Convert this object into a hash.
89
+ def to_hash
90
+ hash = {}
91
+
92
+ instance_variables.each do |var|
93
+ key = var.to_s.delete("@").to_sym
94
+ val = instance_variable_get(var)
95
+
96
+ hash[key] = val
97
+ end
98
+
99
+ hash
100
+ end
101
+ end
102
+ end
103
103
  end
@@ -0,0 +1,116 @@
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
+ class Property < Authlete::Model::Hashable
24
+ include Authlete::Utility
25
+ # The key part. (String)
26
+ attr_accessor :key
27
+
28
+ # The value part. (String)
29
+ attr_accessor :value
30
+
31
+ # The flag to indicate whether this property hidden from or visible
32
+ # to client applications. (Boolean)
33
+ attr_accessor :hidden
34
+
35
+ private
36
+
37
+ # Boolean attributes.
38
+ BOOLEAN_ATTRIBUTES = ::Set.new([ :hidden ])
39
+
40
+ # String attributes.
41
+ STRING_ATTRIBUTES = ::Set.new([ :key, :value ])
42
+
43
+ # The constructor
44
+ def initialize(hash = nil)
45
+ # Set default values to boolean attributes.
46
+ BOOLEAN_ATTRIBUTES.each do |attr|
47
+ send("#{attr}=", false)
48
+ end
49
+
50
+ # Set default values to string attributes.
51
+ STRING_ATTRIBUTES.each do |attr|
52
+ send("#{attr}=", nil)
53
+ end
54
+
55
+ # Set attribute values using the given hash.
56
+ authlete_model_update(hash)
57
+ end
58
+
59
+ def authlete_model_convert_key(key)
60
+ key.to_sym
61
+ end
62
+
63
+ def authlete_model_simple_attribute?(key)
64
+ BOOLEAN_ATTRIBUTES.include?(key) or
65
+ STRING_ATTRIBUTES.include?(key)
66
+ end
67
+
68
+ def authlete_model_update(hash)
69
+ return if hash.nil?
70
+
71
+ hash.each do |key, value|
72
+ key = authlete_model_convert_key(key)
73
+
74
+ if authlete_model_simple_attribute?(key)
75
+ send("#{key}=", value)
76
+ end
77
+ end
78
+
79
+ self
80
+ end
81
+
82
+ public
83
+
84
+ # Construct an instance from the given hash.
85
+ #
86
+ # If the given argument is nil or is not a Hash, nil is returned.
87
+ # Otherwise, Property.new(hash) is returned.
88
+ def self.parse(hash)
89
+ if hash.nil? or (hash.kind_of?(Hash) == false)
90
+ return nil
91
+ end
92
+
93
+ Authlete::Model::Property.new(hash)
94
+ end
95
+
96
+ # Set attribute values using the given hash.
97
+ def update(hash)
98
+ authlete_model_update(hash)
99
+ end
100
+
101
+ # Convert this object into a hash.
102
+ def to_hash
103
+ hash = {}
104
+
105
+ instance_variables.each do |var|
106
+ key = var.to_s.delete("@").to_sym
107
+ val = instance_variable_get(var)
108
+
109
+ hash[key] = val
110
+ end
111
+
112
+ hash
113
+ end
114
+ end
115
+ end
116
+ end
@@ -1,91 +1,91 @@
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::AuthenticationCallbackRequest class
25
- #
26
- # This class represents a request to an authentication callback endpoint.
27
- class AuthenticationCallbackRequest
28
- include Authlete::Utility
29
- # The API key of the service.
30
- attr_accessor :service_api_key
31
-
32
- # The ID of the client application which has triggered the authentication
33
- # callback request.
34
- attr_accessor :client_id
35
-
36
- # The login ID that the end-user input to the login ID field.
37
- attr_accessor :id
38
-
39
- # The password that the end-user input to the password field.
40
- attr_accessor :password
41
-
42
- # Names of requested claims (string array).
43
- attr_accessor :claims
44
-
45
- # Names of requested claim locales (string array). The values come
46
- # from 'claims_locales' request parameter of an authorization request.
47
- attr_accessor :claims_locales
48
-
49
- # The SNS which the end-user used for social login.
50
- # For example, 'FACEBOOK'.
51
- attr_accessor :sns
52
-
53
- # The access token issued at the token endpoint of the SNS.
54
- attr_accessor :access_token
55
-
56
- # The refresh token issued along with the access token.
57
- attr_accessor :refresh_token
58
-
59
- # The duration of the access token.
60
- attr_accessor :expires_in
61
-
62
- # The raw content of the response from the token endpoint of the SNS.
63
- # Correct OAuth 2.0 implementations return 'application/json', but Facebook
64
- # returns 'application/x-www-form-url-encoded'.
65
- attr_accessor :raw_token_response
66
-
67
- # The constructor which takes a hash that represents a JSON request
68
- # to an authentication callback endpoint.
69
- def initialize(hash = {})
70
- @service_api_key = extract_value(hash, :serviceApiKey)
71
- @client_id = extract_value(hash, :clientId)
72
- @id = extract_value(hash, :id)
73
- @password = extract_value(hash, :password)
74
- @claims = extract_value(hash, :claims)
75
- @claims_locales = extract_value(hash, :claimsLocales)
76
- @sns = extract_value(hash, :sns)
77
- @access_token = extract_value(hash, :accessToken)
78
- @refresh_token = extract_value(hash, :refreshToken)
79
- @expires_in = extract_integer_value(hash, :expiresIn)
80
- @raw_token_response = extract_value(hash, :rawTokenResponse)
81
- end
82
-
83
- # Parse a JSON string which represents a request to an authentication
84
- # callback endpoint and generate an instance of AuthenticationCallbackRequest.
85
- def self.parse(json)
86
- AuthenticationCallbackRequest.new(JSON.parse(json))
87
- end
88
- end
89
- end
90
- 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::AuthenticationCallbackRequest class
25
+ #
26
+ # This class represents a request to an authentication callback endpoint.
27
+ class AuthenticationCallbackRequest
28
+ include Authlete::Utility
29
+ # The API key of the service.
30
+ attr_accessor :service_api_key
31
+
32
+ # The ID of the client application which has triggered the authentication
33
+ # callback request.
34
+ attr_accessor :client_id
35
+
36
+ # The login ID that the end-user input to the login ID field.
37
+ attr_accessor :id
38
+
39
+ # The password that the end-user input to the password field.
40
+ attr_accessor :password
41
+
42
+ # Names of requested claims (string array).
43
+ attr_accessor :claims
44
+
45
+ # Names of requested claim locales (string array). The values come
46
+ # from 'claims_locales' request parameter of an authorization request.
47
+ attr_accessor :claims_locales
48
+
49
+ # The SNS which the end-user used for social login.
50
+ # For example, 'FACEBOOK'.
51
+ attr_accessor :sns
52
+
53
+ # The access token issued at the token endpoint of the SNS.
54
+ attr_accessor :access_token
55
+
56
+ # The refresh token issued along with the access token.
57
+ attr_accessor :refresh_token
58
+
59
+ # The duration of the access token.
60
+ attr_accessor :expires_in
61
+
62
+ # The raw content of the response from the token endpoint of the SNS.
63
+ # Correct OAuth 2.0 implementations return 'application/json', but Facebook
64
+ # returns 'application/x-www-form-url-encoded'.
65
+ attr_accessor :raw_token_response
66
+
67
+ # The constructor which takes a hash that represents a JSON request
68
+ # to an authentication callback endpoint.
69
+ def initialize(hash = {})
70
+ @service_api_key = extract_value(hash, :serviceApiKey)
71
+ @client_id = extract_value(hash, :clientId)
72
+ @id = extract_value(hash, :id)
73
+ @password = extract_value(hash, :password)
74
+ @claims = extract_value(hash, :claims)
75
+ @claims_locales = extract_value(hash, :claimsLocales)
76
+ @sns = extract_value(hash, :sns)
77
+ @access_token = extract_value(hash, :accessToken)
78
+ @refresh_token = extract_value(hash, :refreshToken)
79
+ @expires_in = extract_integer_value(hash, :expiresIn)
80
+ @raw_token_response = extract_value(hash, :rawTokenResponse)
81
+ end
82
+
83
+ # Parse a JSON string which represents a request to an authentication
84
+ # callback endpoint and generate an instance of AuthenticationCallbackRequest.
85
+ def self.parse(json)
86
+ AuthenticationCallbackRequest.new(JSON.parse(json))
87
+ end
88
+ end
89
+ end
90
+ end
91
91
  end