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.
- checksums.yaml +4 -4
- data/lib/authlete.rb +24 -1
- data/lib/authlete/api.rb +298 -146
- data/lib/authlete/authentication-server.rb +1 -1
- data/lib/authlete/exception.rb +6 -3
- data/lib/authlete/model/client-extension.rb +135 -135
- data/lib/authlete/model/client-list.rb +128 -128
- data/lib/authlete/model/client.rb +468 -468
- data/lib/authlete/model/hashable.rb +1 -1
- data/lib/authlete/model/pair.rb +102 -102
- data/lib/authlete/model/property.rb +116 -0
- data/lib/authlete/model/request/authentication-callback-request.rb +90 -90
- data/lib/authlete/model/request/authorization-fail-request.rb +107 -104
- data/lib/authlete/model/request/authorization-issue-request.rb +167 -133
- data/lib/authlete/model/request/authorization-request.rb +101 -101
- data/lib/authlete/model/request/client-authorization-delete-request.rb +123 -0
- data/lib/authlete/model/request/client-authorization-get-list-request.rb +123 -0
- data/lib/authlete/model/request/client-authorization-update-request.rb +118 -0
- data/lib/authlete/model/request/client-secret-update-request.rb +121 -0
- data/lib/authlete/model/request/developer-authentication-callback-request.rb +84 -84
- data/lib/authlete/model/request/granted-scopes-request.rb +103 -0
- data/lib/authlete/model/request/introspection-request.rb +117 -39
- data/lib/authlete/model/request/revocation-request.rb +125 -0
- data/lib/authlete/model/request/standard-introspection-request.rb +102 -0
- data/lib/authlete/model/request/token-create-request.rb +250 -0
- data/lib/authlete/model/request/token-fail-request.rb +104 -101
- data/lib/authlete/model/request/token-issue-request.rb +116 -101
- data/lib/authlete/model/request/token-request.rb +127 -121
- data/lib/authlete/model/request/token-update-request.rb +165 -0
- data/lib/authlete/model/request/user-info-issue-request.rb +113 -0
- data/lib/authlete/model/request/user-info-request.rb +102 -0
- data/lib/authlete/model/response/authentication-callback-response.rb +53 -53
- data/lib/authlete/model/response/authorization-fail-response.rb +48 -48
- data/lib/authlete/model/response/authorization-issue-response.rb +85 -48
- data/lib/authlete/model/response/authorization-response.rb +177 -164
- data/lib/authlete/model/response/client-authorization-get-list-response.rb +60 -0
- data/lib/authlete/model/response/client-secret-refresh-response.rb +48 -0
- data/lib/authlete/model/response/client-secret-update-response.rb +48 -0
- data/lib/authlete/model/response/developer-authentication-callback-response.rb +55 -55
- data/lib/authlete/model/response/granted-scopes-get-response.rb +63 -0
- data/lib/authlete/model/response/introspection-response.rb +163 -132
- data/lib/authlete/model/response/revocation-response.rb +49 -0
- data/lib/authlete/model/response/service-creatable-response.rb +50 -50
- data/lib/authlete/model/response/standard-introspection-response.rb +49 -0
- data/lib/authlete/model/response/token-create-response.rb +100 -0
- data/lib/authlete/model/response/token-fail-response.rb +49 -49
- data/lib/authlete/model/response/token-issue-response.rb +138 -49
- data/lib/authlete/model/response/token-response.rb +168 -70
- data/lib/authlete/model/response/token-update-response.rb +62 -0
- data/lib/authlete/model/response/user-info-issue-response.rb +47 -0
- data/lib/authlete/model/response/user-info-response.rb +85 -0
- data/lib/authlete/model/result.rb +44 -44
- data/lib/authlete/model/scope.rb +1 -1
- data/lib/authlete/model/service-list.rb +1 -1
- data/lib/authlete/model/service-owner.rb +1 -1
- data/lib/authlete/model/service.rb +4 -2
- data/lib/authlete/model/sns-credentials.rb +1 -1
- data/lib/authlete/model/tagged-value.rb +97 -97
- data/lib/authlete/utility.rb +1 -1
- data/lib/authlete/version.rb +2 -2
- metadata +24 -2
@@ -1,105 +1,108 @@
|
|
1
|
-
# :nodoc:
|
2
|
-
#
|
3
|
-
# Copyright (C) 2014-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# The
|
29
|
-
attr_accessor :
|
30
|
-
|
31
|
-
# The
|
32
|
-
attr_accessor :
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# The
|
29
|
-
attr_accessor :
|
30
|
-
|
31
|
-
# The
|
32
|
-
attr_accessor :
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
#
|
40
|
-
attr_accessor :
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
#
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|