authlete 1.0.24 → 1.1.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/.gitignore +2 -1
- data/Makefile +40 -0
- data/Rakefile +5 -0
- data/authlete.gemspec +2 -2
- data/lib/authlete.rb +28 -9
- data/lib/authlete/api.rb +146 -321
- data/lib/authlete/authentication-server.rb +2 -2
- data/lib/authlete/exception.rb +14 -15
- data/lib/authlete/model/base.rb +30 -0
- data/lib/authlete/model/client-extension.rb +17 -119
- data/lib/authlete/model/client.rb +196 -345
- data/lib/authlete/model/hashable.rb +13 -33
- data/lib/authlete/model/named-uri.rb +13 -74
- data/lib/authlete/model/pair.rb +13 -74
- data/lib/authlete/model/param-initializer.rb +45 -0
- data/lib/authlete/model/property.rb +15 -85
- data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
- data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
- data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
- data/lib/authlete/model/request/authorization-request.rb +8 -73
- data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
- data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
- data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
- data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
- data/lib/authlete/model/request/base.rb +26 -0
- data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
- data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
- data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
- data/lib/authlete/model/request/client-registration-request.rb +49 -0
- data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
- data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
- data/lib/authlete/model/request/device-authorization-request.rb +63 -0
- data/lib/authlete/model/request/device-complete-request.rb +99 -0
- data/lib/authlete/model/request/device-verification-request.rb +40 -0
- data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
- data/lib/authlete/model/request/introspection-request.rb +24 -83
- data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
- data/lib/authlete/model/request/revocation-request.rb +14 -88
- data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
- data/lib/authlete/model/request/token-create-request.rb +52 -183
- data/lib/authlete/model/request/token-fail-request.rb +12 -74
- data/lib/authlete/model/request/token-issue-request.rb +22 -80
- data/lib/authlete/model/request/token-request.rb +44 -81
- data/lib/authlete/model/request/token-update-request.rb +35 -121
- data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
- data/lib/authlete/model/request/user-info-request.rb +25 -70
- data/lib/authlete/model/response/access-token.rb +96 -0
- data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
- data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
- data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
- data/lib/authlete/model/response/authorization-response.rb +97 -123
- data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
- data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
- data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
- data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
- data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
- data/lib/authlete/model/response/client-list-response.rb +58 -0
- data/lib/authlete/model/response/client-registration-response.rb +50 -0
- data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
- data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
- data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
- data/lib/authlete/model/response/device-authorization-response.rb +134 -0
- data/lib/authlete/model/response/device-complete-response.rb +39 -0
- data/lib/authlete/model/response/device-verification-response.rb +96 -0
- data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
- data/lib/authlete/model/response/introspection-response.rb +64 -58
- data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
- data/lib/authlete/model/response/revocation-response.rb +12 -15
- data/lib/authlete/model/response/service-list-response.rb +54 -0
- data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
- data/lib/authlete/model/response/token-create-response.rb +50 -55
- data/lib/authlete/model/response/token-fail-response.rb +14 -17
- data/lib/authlete/model/response/token-issue-response.rb +49 -62
- data/lib/authlete/model/response/token-list-response.rb +64 -0
- data/lib/authlete/model/response/token-response.rb +59 -79
- data/lib/authlete/model/response/token-update-response.rb +28 -23
- data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
- data/lib/authlete/model/response/user-info-response.rb +48 -42
- data/lib/authlete/model/result.rb +14 -13
- data/lib/authlete/model/scope.rb +29 -119
- data/lib/authlete/model/service-owner.rb +32 -116
- data/lib/authlete/model/service.rb +464 -685
- data/lib/authlete/model/sns-credentials.rb +18 -91
- data/lib/authlete/model/tagged-value.rb +14 -69
- data/lib/authlete/utility.rb +3 -32
- data/lib/authlete/version.rb +3 -3
- data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
- data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
- data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
- data/test/authlete/model/request/test_authorization-request.rb +57 -0
- data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
- data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
- data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
- data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
- data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
- data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
- data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
- data/test/authlete/model/request/test_client-registration-request.rb +68 -0
- data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
- data/test/authlete/model/request/test_device-complete-request.rb +102 -0
- data/test/authlete/model/request/test_device-verification-request.rb +57 -0
- data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
- data/test/authlete/model/request/test_introspection-request.rb +79 -0
- data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
- data/test/authlete/model/request/test_revocation-request.rb +67 -0
- data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
- data/test/authlete/model/request/test_token-create-request.rb +110 -0
- data/test/authlete/model/request/test_token-fail-request.rb +63 -0
- data/test/authlete/model/request/test_token-issue-request.rb +70 -0
- data/test/authlete/model/request/test_token-request.rb +94 -0
- data/test/authlete/model/request/test_token-update-request.rb +82 -0
- data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
- data/test/authlete/model/request/test_user-info-request.rb +75 -0
- data/test/authlete/model/response/test_access-token.rb +101 -0
- data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
- data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
- data/test/authlete/model/response/test_authorization-response.rb +145 -0
- data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
- data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
- data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
- data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
- data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
- data/test/authlete/model/response/test_client-list-response.rb +79 -0
- data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
- data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
- data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
- data/test/authlete/model/response/test_device-complete-response.rb +64 -0
- data/test/authlete/model/response/test_device-verification-response.rb +112 -0
- data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
- data/test/authlete/model/response/test_introspection-response.rb +127 -0
- data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
- data/test/authlete/model/response/test_revocation-response.rb +68 -0
- data/test/authlete/model/response/test_service-list-response.rb +72 -0
- data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
- data/test/authlete/model/response/test_token-create-response.rb +107 -0
- data/test/authlete/model/response/test_token-fail-response.rb +68 -0
- data/test/authlete/model/response/test_token-issue-response.rb +127 -0
- data/test/authlete/model/response/test_token-list-response.rb +84 -0
- data/test/authlete/model/response/test_token-response.rb +147 -0
- data/test/authlete/model/response/test_token-update-response.rb +87 -0
- data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
- data/test/authlete/model/response/test_user-info-response.rb +107 -0
- data/test/authlete/model/test_client-extension.rb +95 -0
- data/test/authlete/model/test_client.rb +461 -0
- data/test/authlete/model/test_named-uri.rb +85 -0
- data/test/authlete/model/test_pair.rb +85 -0
- data/test/authlete/model/test_property.rb +90 -0
- data/test/authlete/model/test_result.rb +68 -0
- data/test/authlete/model/test_scope.rb +106 -0
- data/test/authlete/model/test_service-owner.rb +80 -0
- data/test/authlete/model/test_service.rb +614 -0
- data/test/authlete/model/test_sns-credentials.rb +88 -0
- data/test/authlete/model/test_tagged-value.rb +83 -0
- data/test/authlete/test_exception.rb +70 -0
- metadata +169 -9
- data/lib/authlete/model/client-list.rb +0 -129
- data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
- data/lib/authlete/model/response/service-creatable-response.rb +0 -51
- data/lib/authlete/model/service-list.rb +0 -128
@@ -1,6 +1,6 @@
|
|
1
1
|
# :nodoc:
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014-
|
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,91 +15,29 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
|
18
|
-
require 'set'
|
19
|
-
|
20
|
-
|
21
18
|
module Authlete
|
22
19
|
module Model
|
23
20
|
module Request
|
24
|
-
|
25
|
-
|
26
|
-
# This class represents a request to Authlete's /api/auth/token/fail API.
|
27
|
-
class TokenFailRequest < Authlete::Model::Hashable
|
28
|
-
# The ticket issued by Authlete's /api/auth/token API. (String)
|
21
|
+
class TokenFailRequest < Authlete::Model::Request::Base
|
22
|
+
|
29
23
|
attr_accessor :ticket
|
30
24
|
|
31
|
-
# The reason of the failure. (String)
|
32
25
|
attr_accessor :reason
|
33
26
|
|
34
27
|
private
|
35
28
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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)
|
29
|
+
def defaults
|
30
|
+
{
|
31
|
+
ticket: nil,
|
32
|
+
reason: nil
|
33
|
+
}
|
49
34
|
end
|
50
35
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
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, TokenFailRequest.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 TokenFailRequest.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
|
36
|
+
def set_params(hash)
|
37
|
+
@ticket = hash[:ticket]
|
38
|
+
@reason = hash[:reason]
|
101
39
|
end
|
102
40
|
end
|
103
41
|
end
|
104
42
|
end
|
105
|
-
end
|
43
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# :nodoc:
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014-
|
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,103 +15,45 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
|
18
|
-
require 'set'
|
19
|
-
|
20
|
-
|
21
18
|
module Authlete
|
22
19
|
module Model
|
23
20
|
module Request
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
class TokenIssueRequest < Authlete::Model::Hashable
|
28
|
-
# The ticket issued by Authlete's /api/auth/authorization API. (String)
|
21
|
+
class TokenIssueRequest < Authlete::Model::Request::Base
|
22
|
+
include Authlete::Utility
|
23
|
+
|
29
24
|
attr_accessor :ticket
|
30
25
|
|
31
|
-
# The subject (end-user) managed by the service. (String)
|
32
26
|
attr_accessor :subject
|
33
27
|
|
34
|
-
# Extra properties to associate with a newly created access token.
|
35
|
-
# (String)
|
36
28
|
attr_accessor :properties
|
37
29
|
|
38
30
|
private
|
39
31
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# Set default values to string attributes.
|
47
|
-
STRING_ATTRIBUTES.each do |attr|
|
48
|
-
send("#{attr}=", nil)
|
49
|
-
end
|
50
|
-
|
51
|
-
@properties = nil
|
52
|
-
|
53
|
-
# Set attribute values using the given hash.
|
54
|
-
authlete_model_update(hash)
|
55
|
-
end
|
56
|
-
|
57
|
-
def authlete_model_convert_key(key)
|
58
|
-
key.to_sym
|
59
|
-
end
|
60
|
-
|
61
|
-
def authlete_model_simple_attribute?(key)
|
62
|
-
STRING_ATTRIBUTES.include?(key)
|
32
|
+
def defaults
|
33
|
+
{
|
34
|
+
ticket: nil,
|
35
|
+
subject: nil,
|
36
|
+
properties: nil
|
37
|
+
}
|
63
38
|
end
|
64
39
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
hash
|
69
|
-
key = authlete_model_convert_key(key)
|
70
|
-
|
71
|
-
if authlete_model_simple_attribute?(key)
|
72
|
-
send("#{key}=", value)
|
73
|
-
elsif key == :properties
|
74
|
-
@properties = get_parsed_array(value) do |element|
|
75
|
-
Authlete::Model::Property.parse(element)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
self
|
40
|
+
def set_params(hash)
|
41
|
+
@ticket = hash[:ticket]
|
42
|
+
@subject = hash[:subject]
|
43
|
+
@properties = get_parsed_array(hash[:properties]) { |e| Authlete::Model::Property.parse(e) }
|
81
44
|
end
|
82
45
|
|
83
|
-
|
46
|
+
def to_hash_value(key, var)
|
47
|
+
raw_val = instance_variable_get(var)
|
84
48
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
if hash.nil? or (hash.kind_of?(Hash) == false)
|
91
|
-
return nil
|
49
|
+
case key
|
50
|
+
when :properties
|
51
|
+
raw_val&.map { |e| e.to_hash }
|
52
|
+
else
|
53
|
+
raw_val
|
92
54
|
end
|
93
|
-
|
94
|
-
return TokenIssueRequest.new(hash)
|
95
|
-
end
|
96
|
-
|
97
|
-
# Convert this object into a hash.
|
98
|
-
def to_hash
|
99
|
-
hash = {}
|
100
|
-
|
101
|
-
instance_variables.each do |var|
|
102
|
-
key = var.to_s.delete("@").to_sym
|
103
|
-
val = instance_variable_get(var)
|
104
|
-
|
105
|
-
if authlete_model_simple_attribute?(key) or val.nil?
|
106
|
-
hash[key] = val
|
107
|
-
elsif key == :properties
|
108
|
-
hash[key] = val.map { |element| element.to_hash }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
hash
|
113
55
|
end
|
114
56
|
end
|
115
57
|
end
|
116
58
|
end
|
117
|
-
end
|
59
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# :nodoc:
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014-
|
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,114 +15,77 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
|
18
|
-
require 'set'
|
19
|
-
|
20
|
-
|
21
18
|
module Authlete
|
22
19
|
module Model
|
23
20
|
module Request
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
class TokenRequest < Authlete::Model::Hashable
|
28
|
-
# OAuth 2.0 token request parameters. (String)
|
21
|
+
class TokenRequest < Authlete::Model::Request::Base
|
22
|
+
include Authlete::Utility
|
23
|
+
|
29
24
|
attr_accessor :parameters
|
30
25
|
|
31
|
-
# Client ID. (String)
|
32
26
|
attr_accessor :clientId
|
33
27
|
alias_method :client_id, :clientId
|
34
28
|
alias_method :client_id=, :clientId=
|
35
29
|
|
36
|
-
# Client Secret. (String)
|
37
30
|
attr_accessor :clientSecret
|
38
31
|
alias_method :client_secret, :clientSecret
|
39
32
|
alias_method :client_secret=, :clientSecret=
|
40
33
|
|
41
|
-
# Extra properties to associate with an access token. (String)
|
42
34
|
attr_accessor :properties
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
STRING_ATTRIBUTES = ::Set.new([ :parameters, :clientId, :clientSecret, :properties ])
|
48
|
-
|
49
|
-
# Mapping from snake cases to camel cases.
|
50
|
-
SNAKE_TO_CAMEL = {
|
51
|
-
:client_id => :clientId,
|
52
|
-
:client_secret => :clientSecret
|
53
|
-
}
|
54
|
-
|
55
|
-
# The constructor which takes a hash that represents a JSON request
|
56
|
-
# to Authlete's /api/auth/token API.
|
57
|
-
def initialize(hash = nil)
|
58
|
-
# Set default values to string attributes.
|
59
|
-
STRING_ATTRIBUTES.each do |attr|
|
60
|
-
send("#{attr}=", nil)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Set attribute values using the given hash.
|
64
|
-
authlete_model_update(hash)
|
65
|
-
end
|
66
|
-
|
67
|
-
def authlete_model_convert_key(key)
|
68
|
-
key = key.to_sym
|
69
|
-
|
70
|
-
# Convert snakecase to camelcase, if necessary.
|
71
|
-
if SNAKE_TO_CAMEL.has_key?(key)
|
72
|
-
key = SNAKE_TO_CAMEL[key]
|
73
|
-
end
|
36
|
+
attr_accessor :clientCertificate
|
37
|
+
alias_method :client_certificate, :clientCertificate
|
38
|
+
alias_method :client_certificate=, :clientCertificate=
|
74
39
|
|
75
|
-
|
76
|
-
|
40
|
+
attr_accessor :clientCertificatePath
|
41
|
+
alias_method :client_certificate_path, :clientCertificatePath
|
42
|
+
alias_method :client_certificate_path=, :clientCertificatePath=
|
77
43
|
|
78
|
-
|
79
|
-
STRING_ATTRIBUTES.include?(key)
|
80
|
-
end
|
44
|
+
attr_accessor :dpop
|
81
45
|
|
82
|
-
|
83
|
-
return if hash.nil?
|
46
|
+
attr_accessor :htu
|
84
47
|
|
85
|
-
|
86
|
-
key = authlete_model_convert_key(key)
|
48
|
+
attr_accessor :htm
|
87
49
|
|
88
|
-
|
89
|
-
send("#{key}=", value)
|
90
|
-
end
|
91
|
-
end
|
50
|
+
private
|
92
51
|
|
93
|
-
|
52
|
+
def defaults
|
53
|
+
{
|
54
|
+
parameters: nil,
|
55
|
+
clientId: nil,
|
56
|
+
clientSecret: nil,
|
57
|
+
properties: nil,
|
58
|
+
clientCertificate: nil,
|
59
|
+
clientCertificatePath: nil,
|
60
|
+
dpop: nil,
|
61
|
+
htu: nil,
|
62
|
+
htm: nil
|
63
|
+
}
|
94
64
|
end
|
95
65
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
return TokenRequest.new(hash)
|
66
|
+
def set_params(hash)
|
67
|
+
@parameters = hash[:parameters]
|
68
|
+
@clientId = hash[:clientId]
|
69
|
+
@clientSecret = hash[:clientSecret]
|
70
|
+
@properties = get_parsed_array(hash[:properties]) { |e| Authlete::Model::Property.parse(e) }
|
71
|
+
@clientCertificate = hash[:clientCertificate]
|
72
|
+
@clientCertificatePath = hash[:clientCertificatePath]
|
73
|
+
@dpop = hash[:dpop]
|
74
|
+
@htu = hash[:htu]
|
75
|
+
@htm = hash[:htm]
|
108
76
|
end
|
109
77
|
|
110
|
-
|
111
|
-
|
112
|
-
hash = {}
|
78
|
+
def to_hash_value(key, var)
|
79
|
+
raw_val = instance_variable_get(var)
|
113
80
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
hash[key] = val
|
120
|
-
end
|
81
|
+
case key
|
82
|
+
when :properties
|
83
|
+
raw_val&.map { |e| e.to_hash }
|
84
|
+
else
|
85
|
+
raw_val
|
121
86
|
end
|
122
|
-
|
123
|
-
hash
|
124
87
|
end
|
125
88
|
end
|
126
89
|
end
|
127
90
|
end
|
128
|
-
end
|
91
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# :nodoc:
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014-
|
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,151 +15,65 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
|
18
|
-
require 'set'
|
19
|
-
|
20
|
-
|
21
18
|
module Authlete
|
22
19
|
module Model
|
23
20
|
module Request
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
class TokenUpdateRequest < Authlete::Model::Hashable
|
28
|
-
# An existing access token. (String)
|
21
|
+
class TokenUpdateRequest < Authlete::Model::Request::Base
|
22
|
+
include Authlete::Utility
|
23
|
+
|
29
24
|
attr_accessor :accessToken
|
30
25
|
alias_method :access_token, :accessToken
|
31
26
|
alias_method :access_token=, :accessToken=
|
32
27
|
|
33
|
-
#A new date at which the access token will expire in milliseconds
|
34
|
-
# since the Unix epoch (1970-01-01). If the accessTokenExpiresAt request
|
35
|
-
# parameter is not included in a request or its value is 0 (or negative),
|
36
|
-
# the expiration date of the access token is not changed. (Integer)
|
37
28
|
attr_accessor :accessTokenExpiresAt
|
38
29
|
alias_method :access_token_expires_at, :accessTokenExpiresAt
|
39
30
|
alias_method :access_token_expires_at=, :accessTokenExpiresAt=
|
40
31
|
|
41
|
-
# A new set of scopes assigned to the access token. Scopes that are not
|
42
|
-
# supported by the service and those that the client application associated
|
43
|
-
# with the access token is not allowed to request are ignored on the
|
44
|
-
# server side. If the scopes request parameter is not included in a
|
45
|
-
# request or its value is nil, the scopes of the access token are not
|
46
|
-
# changed. (String array)
|
47
32
|
attr_accessor :scopes
|
48
33
|
|
49
|
-
# A new set of properties assigned to the access token. If the properties
|
50
|
-
# request parameter is not included in a request or its value is nil,
|
51
|
-
# the properties of the access token are not changed.
|
52
|
-
# (Property array)
|
53
34
|
attr_accessor :properties
|
54
35
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
INTEGER_ATTRIBUTES = ::Set.new([ :accessTokenExpiresAt ])
|
59
|
-
|
60
|
-
# String attributes.
|
61
|
-
STRING_ATTRIBUTES = ::Set.new([ :accessToken ])
|
62
|
-
|
63
|
-
# String array attributes.
|
64
|
-
STRING_ARRAY_ATTRIBUTES = ::Set.new([ :scopes ])
|
65
|
-
|
66
|
-
# Mapping from snake cases to camel cases.
|
67
|
-
SNAKE_TO_CAMEL = {
|
68
|
-
:access_token => :accessToken,
|
69
|
-
:access_expires_at => :accessTokenExpiresAt
|
70
|
-
}
|
71
|
-
|
72
|
-
# The constructor which takes a hash that represents a JSON request to
|
73
|
-
# Authlete's /api/auth/token/update API.
|
74
|
-
def initialize(hash = nil)
|
75
|
-
# Set default values to integer attributes.
|
76
|
-
INTEGER_ATTRIBUTES.each do |attr|
|
77
|
-
send("#{attr}=", 0)
|
78
|
-
end
|
79
|
-
|
80
|
-
# Set default values to string attributes.
|
81
|
-
STRING_ATTRIBUTES.each do |attr|
|
82
|
-
send("#{attr}=", nil)
|
83
|
-
end
|
84
|
-
|
85
|
-
# Set default values to string array attributes.
|
86
|
-
STRING_ARRAY_ATTRIBUTES.each do |attr|
|
87
|
-
send("#{attr}=", nil)
|
88
|
-
end
|
89
|
-
|
90
|
-
@properties = nil
|
91
|
-
|
92
|
-
# Set attribute values using the given hash.
|
93
|
-
authlete_model_update(hash)
|
94
|
-
end
|
95
|
-
|
96
|
-
def authlete_model_convert_key(key)
|
97
|
-
key = key.to_sym
|
98
|
-
|
99
|
-
# Convert snakecase to camelcase, if necessary.
|
100
|
-
if SNAKE_TO_CAMEL.has_key?(key)
|
101
|
-
key = SNAKE_TO_CAMEL[key]
|
102
|
-
end
|
103
|
-
|
104
|
-
key
|
105
|
-
end
|
106
|
-
|
107
|
-
def authlete_model_simple_attribute?(key)
|
108
|
-
INTEGER_ATTRIBUTES.include?(key) or
|
109
|
-
STRING_ATTRIBUTES.include?(key) or
|
110
|
-
STRING_ARRAY_ATTRIBUTES.include?(key)
|
111
|
-
end
|
36
|
+
attr_accessor :certificateThumbprint
|
37
|
+
alias_method :certificate_thumbprint, :certificateThumbprint
|
38
|
+
alias_method :certificate_thumbprint=, :certificateThumbprint=
|
112
39
|
|
113
|
-
|
114
|
-
|
40
|
+
attr_accessor :dpopKeyThumbprint
|
41
|
+
alias_method :dpop_key_thumbprint, :dpopKeyThumbprint
|
42
|
+
alias_method :dpop_key_thumbprint=, :dpopKeyThumbprint=
|
115
43
|
|
116
|
-
|
117
|
-
key = authlete_model_convert_key(key)
|
118
|
-
|
119
|
-
if authlete_model_simple_attribute?(key)
|
120
|
-
send("#{key}=", value)
|
121
|
-
elsif key == :properties
|
122
|
-
@properties = get_parsed_array(value) do |element|
|
123
|
-
Authlete::Model::Property.parse(element)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
44
|
+
private
|
127
45
|
|
128
|
-
|
46
|
+
def defaults
|
47
|
+
{
|
48
|
+
accessToken: nil,
|
49
|
+
accessTokenExpiresAt: 0,
|
50
|
+
scopes: nil,
|
51
|
+
properties: nil,
|
52
|
+
certificateThumbprint: nil,
|
53
|
+
dpopKeyThumbprint: nil
|
54
|
+
}
|
129
55
|
end
|
130
56
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
if hash.nil? or (hash.kind_of?(Hash) == false)
|
139
|
-
return nil
|
140
|
-
end
|
141
|
-
|
142
|
-
return TokenUpdateRequest.new(hash)
|
57
|
+
def set_params(hash)
|
58
|
+
@accessToken = hash[:accessToken]
|
59
|
+
@accessTokenExpiresAt = hash[:accessTokenExpiresAt]
|
60
|
+
@scopes = hash[:scopes]
|
61
|
+
@properties = get_parsed_array(hash[:properties]) { |e| Authlete::Model::Property.parse(e) }
|
62
|
+
@certificateThumbprint = hash[:certificateThumbprint]
|
63
|
+
@dpopKeyThumbprint = hash[:dpopKeyThumbprint]
|
143
64
|
end
|
144
65
|
|
145
|
-
|
146
|
-
|
147
|
-
hash = {}
|
66
|
+
def to_hash_value(key, var)
|
67
|
+
raw_val = instance_variable_get(var)
|
148
68
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
hash[key] = val
|
155
|
-
elsif key == :properties
|
156
|
-
hash[key] = val.map { |element| element.to_hash }
|
157
|
-
end
|
69
|
+
case key
|
70
|
+
when :properties
|
71
|
+
raw_val&.map { |e| e.to_hash }
|
72
|
+
else
|
73
|
+
raw_val
|
158
74
|
end
|
159
|
-
|
160
|
-
hash
|
161
75
|
end
|
162
76
|
end
|
163
77
|
end
|
164
78
|
end
|
165
|
-
end
|
79
|
+
end
|