authlete 1.0.21 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Makefile +40 -0
- data/README.md +20 -20
- data/Rakefile +5 -0
- data/authlete.gemspec +2 -2
- data/lib/authlete.rb +28 -9
- data/lib/authlete/api.rb +153 -322
- data/lib/authlete/authentication-server.rb +230 -230
- 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 +203 -338
- 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 +68 -158
- data/lib/authlete/model/service-owner.rb +32 -116
- data/lib/authlete/model/service.rb +672 -837
- data/lib/authlete/model/sns-credentials.rb +51 -124
- data/lib/authlete/model/tagged-value.rb +14 -69
- data/lib/authlete/utility.rb +70 -99
- 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 +624 -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 +173 -13
- 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,111 +15,37 @@
|
|
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/revocation API.
|
27
|
-
class RevocationRequest < Authlete::Model::Hashable
|
28
|
-
# The OAuth 2.0 revocation request parameters. (String)
|
21
|
+
class RevocationRequest < Authlete::Model::Request::Base
|
22
|
+
|
29
23
|
attr_accessor :parameters
|
30
24
|
|
31
|
-
# Client ID. (String)
|
32
25
|
attr_accessor :clientId
|
33
26
|
alias_method :client_id, :clientId
|
34
27
|
alias_method :client_id=, :clientId=
|
35
28
|
|
36
|
-
# Client Secret. (String)
|
37
29
|
attr_accessor :clientSecret
|
38
30
|
alias_method :client_secret, :clientSecret
|
39
31
|
alias_method :client_secret=, :clientSecret=
|
40
32
|
|
41
33
|
private
|
42
34
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
:client_secret => :clientSecret
|
50
|
-
}
|
51
|
-
|
52
|
-
# The constructor which takes a hash that represents a JSON request to
|
53
|
-
# Authlete's /api/auth/revocation API.
|
54
|
-
def initialize(hash = nil)
|
55
|
-
# Set default values to string attributes.
|
56
|
-
STRING_ATTRIBUTES.each do |attr|
|
57
|
-
send("#{attr}=", nil)
|
58
|
-
end
|
59
|
-
|
60
|
-
# Set attribute values using the given hash.
|
61
|
-
authlete_model_update(hash)
|
62
|
-
end
|
63
|
-
|
64
|
-
def authlete_model_convert_key(key)
|
65
|
-
key = key.to_sym
|
66
|
-
|
67
|
-
# Convert snakecase to camelcase, if necessary.
|
68
|
-
if SNAKE_TO_CAMEL.has_key?(key)
|
69
|
-
key = SNAKE_TO_CAMEL[key]
|
70
|
-
end
|
71
|
-
|
72
|
-
key
|
73
|
-
end
|
74
|
-
|
75
|
-
def authlete_model_simple_attribute?(key)
|
76
|
-
STRING_ATTRIBUTES.include?(key)
|
35
|
+
def defaults
|
36
|
+
{
|
37
|
+
parameters: nil,
|
38
|
+
clientId: nil,
|
39
|
+
clientSecret: nil
|
40
|
+
}
|
77
41
|
end
|
78
42
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
key = authlete_model_convert_key(key)
|
84
|
-
|
85
|
-
if authlete_model_simple_attribute?(key)
|
86
|
-
send("#{key}=", value)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
self
|
91
|
-
end
|
92
|
-
|
93
|
-
public
|
94
|
-
|
95
|
-
# Construct an instance from the given hash.
|
96
|
-
#
|
97
|
-
# If the given argument is nil or is not a Hash, nil is returned.
|
98
|
-
# Otherwise, RevocationRequest.new(hash) is returned.
|
99
|
-
def self.parse(hash)
|
100
|
-
if hash.nil? or (hash.kind_of?(Hash) == false)
|
101
|
-
return nil
|
102
|
-
end
|
103
|
-
|
104
|
-
return RevocationRequest.new(hash)
|
105
|
-
end
|
106
|
-
|
107
|
-
# Convert this object into a hash.
|
108
|
-
def to_hash
|
109
|
-
hash = {}
|
110
|
-
|
111
|
-
instance_variables.each do |var|
|
112
|
-
key = var.to_s.delete("@").to_sym
|
113
|
-
val = instance_variable_get(var)
|
114
|
-
|
115
|
-
if authlete_model_simple_attribute?(key) or val.nil?
|
116
|
-
hash[key] = val
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
hash
|
43
|
+
def set_params(hash)
|
44
|
+
@parameters = hash[:parameters]
|
45
|
+
@clientId = hash[:clientId]
|
46
|
+
@clientSecret = hash[:clientSecret]
|
121
47
|
end
|
122
48
|
end
|
123
49
|
end
|
124
50
|
end
|
125
|
-
end
|
51
|
+
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,88 +15,23 @@
|
|
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/introspection/standard API.
|
27
|
-
class StandardIntrospectionRequest < Authlete::Model::Hashable
|
28
|
-
# The OAuth 2.0 introspection request parameters. (String)
|
21
|
+
class StandardIntrospectionRequest < Authlete::Model::Request::Base
|
22
|
+
|
29
23
|
attr_accessor :parameters
|
30
24
|
|
31
25
|
private
|
32
26
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# The constructor which takes a hash that represents a JSON request to
|
37
|
-
# Authlete's /api/auth/introspection/standard API.
|
38
|
-
def initialize(hash = nil)
|
39
|
-
# Set default values to string attributes.
|
40
|
-
STRING_ATTRIBUTES.each do |attr|
|
41
|
-
send("#{attr}=", nil)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Set attribute values using the given hash.
|
45
|
-
authlete_model_update(hash)
|
27
|
+
def defaults
|
28
|
+
{ parameters: nil }
|
46
29
|
end
|
47
30
|
|
48
|
-
def
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
def authlete_model_simple_attribute?(key)
|
53
|
-
STRING_ATTRIBUTES.include?(key)
|
54
|
-
end
|
55
|
-
|
56
|
-
def authlete_model_update(hash)
|
57
|
-
return if hash.nil?
|
58
|
-
|
59
|
-
hash.each do |key, value|
|
60
|
-
key = authlete_model_convert_key(key)
|
61
|
-
|
62
|
-
if authlete_model_simple_attribute?(key)
|
63
|
-
send("#{key}=", value)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
self
|
68
|
-
end
|
69
|
-
|
70
|
-
public
|
71
|
-
|
72
|
-
# Construct an instance from the given hash.
|
73
|
-
#
|
74
|
-
# If the given argument is nil or is not a Hash, nil is returned.
|
75
|
-
# Otherwise, StandardIntrospectionRequest.new(hash) is returned.
|
76
|
-
def self.parse(hash)
|
77
|
-
if hash.nil? or (hash.kind_of?(Hash) == false)
|
78
|
-
return nil
|
79
|
-
end
|
80
|
-
|
81
|
-
return StandardIntrospectionRequest.new(hash)
|
82
|
-
end
|
83
|
-
|
84
|
-
# Convert this object into a hash.
|
85
|
-
def to_hash
|
86
|
-
hash = {}
|
87
|
-
|
88
|
-
instance_variables.each do |var|
|
89
|
-
key = var.to_s.delete("@").to_sym
|
90
|
-
val = instance_variable_get(var)
|
91
|
-
|
92
|
-
if authlete_model_simple_attribute?(key) or val.nil?
|
93
|
-
hash[key] = val
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
hash
|
31
|
+
def set_params(hash)
|
32
|
+
@parameters = hash[:parameters]
|
98
33
|
end
|
99
34
|
end
|
100
35
|
end
|
101
36
|
end
|
102
|
-
end
|
37
|
+
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,236 +15,105 @@
|
|
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 TokenCreateRequest < Authlete::Model::Hashable
|
28
|
-
# The grant type for a newly created access token. One of the following.
|
29
|
-
# "REFRESH_TOKEN" is not allowed.
|
30
|
-
#
|
31
|
-
# "AUTHORIZATION_CODE"
|
32
|
-
# "IMPLICIT"
|
33
|
-
# "PASSWORD"
|
34
|
-
# "CLINET_CREDENTIALS"
|
35
|
-
#
|
36
|
-
# When "grantType" is either "IMPLICIT" or "CLIENT_CREDENTIALS", a
|
37
|
-
# refresh token is not issued. (String)
|
21
|
+
class TokenCreateRequest < Authlete::Model::Request::Base
|
22
|
+
include Authlete::Utility
|
23
|
+
|
38
24
|
attr_accessor :grantType
|
39
25
|
alias_method :grant_type, :grantType
|
40
26
|
alias_method :grant_type=, :grantType=
|
41
27
|
|
42
|
-
# The ID of the client application which will be associated with a
|
43
|
-
# newly created access token. (Integer)
|
44
28
|
attr_accessor :clientId
|
45
29
|
alias_method :client_id, :clientId
|
46
30
|
alias_method :client_id=, :clientId=
|
47
31
|
|
48
|
-
# The subject (= unique identifier) of the user who will be associated
|
49
|
-
# with a newly created access token. This parameter is required unless
|
50
|
-
# the grant type is CLIENT_CREDENTIALS. (String)
|
51
32
|
attr_accessor :subject
|
52
33
|
|
53
|
-
# The scopes which will be associated with a newly created access token.
|
54
|
-
# Scopes that are not supported by the service cannot be specified and
|
55
|
-
# requesting them will cause an error. (String array)
|
56
34
|
attr_accessor :scopes
|
57
35
|
|
58
|
-
# The duration of a newly created access token in seconds. If the value
|
59
|
-
# is 0, the duration is determined according to the settings of the
|
60
|
-
# service. (Integer)
|
61
36
|
attr_accessor :accessTokenDuration
|
62
37
|
alias_method :access_token_duration, :accessTokenDuration
|
63
38
|
alias_method :access_token_duration=, :accessTokenDuration=
|
64
39
|
|
65
|
-
# The duration of a newly created refresh token in seconds. If the value
|
66
|
-
# is 0, the duration is determined according to the settings of the
|
67
|
-
# service.
|
68
|
-
# A refresh token is not created (1) if the service does not support
|
69
|
-
# "REFRESH_TOKEN", or (2) if the specified grant type is either "IMPLICIT"
|
70
|
-
# or "CLIENT_CREDENTIALS". (Integer)
|
71
40
|
attr_accessor :refreshTokenDuration
|
72
41
|
alias_method :refresh_token_duration, :refreshTokenDuration
|
73
42
|
alias_method :refresh_token_duration=, :refreshTokenDuration=
|
74
43
|
|
75
|
-
# Extra properties to associate with a newly created access token.
|
76
|
-
# (Property array)
|
77
44
|
attr_accessor :properties
|
78
45
|
|
79
|
-
# A boolean request parameter which indicates whether to emulate that
|
80
|
-
# the client ID alias is used instead of the original numeric client
|
81
|
-
# ID when a new access token is created.
|
82
|
-
# This has an effect only on the value of the "aud" claim in a response
|
83
|
-
# from UserInfo endpoint. When you access the UserInfo endpoint
|
84
|
-
# (which is expected to be implemented using Authlete's /api/auth/userinfo
|
85
|
-
# API and /api/auth/userinfo/issue API) with an access token which
|
86
|
-
# has been created using Authlete's /api/auth/token/create API with
|
87
|
-
# this property (clientIdAliasUsed) "true", the client ID alias is used
|
88
|
-
# as the value of the "aud" claim in a response from the UserInfo endpoint.
|
89
|
-
# Note that if a client ID alias is not assigned to the client when
|
90
|
-
# Authlete's /api/auth/token/create API is called, this property
|
91
|
-
# (clientIdAliasUsed) has no effect (it is always regarded as "false").
|
92
|
-
# (String)
|
93
46
|
attr_accessor :clientIdAlias
|
94
47
|
alias_method :client_id_alias, :clientIdAlias
|
95
48
|
alias_method :client_id_alias=, :clientIdAlias=
|
96
49
|
|
97
|
-
# The value of the new access token.
|
98
|
-
# The /api/auth/token/create API generates an access token. Therefore,
|
99
|
-
# callers of the API do not have to specify values of newly created
|
100
|
-
# access tokens. However, in some cases, for example, if you want to
|
101
|
-
# migrate existing access tokens from an old system to Authlete, you
|
102
|
-
# may want to specify values of access tokens. In such a case, you
|
103
|
-
# can specify the value of a newly created access token by passing
|
104
|
-
# a non-nil value as the value of accessToken request parameter.
|
105
|
-
# The implementation of the /api/auth/token/create uses the value of
|
106
|
-
# the accessToken request parameter instead of generating a new value
|
107
|
-
# when the request parameter holds a non-nil value.
|
108
|
-
# Note that if the hash value of the specified access token already
|
109
|
-
# exists in Authlete's database, the access token cannot be inserted
|
110
|
-
# and the /api/auth/token/create API will report an error.
|
111
|
-
# (String)
|
112
50
|
attr_accessor :accessToken
|
113
51
|
alias_method :access_token, :accessToken
|
114
52
|
alias_method :access_token=, :accessToken=
|
115
53
|
|
116
|
-
# The value of the new refresh token.
|
117
|
-
# The /api/auth/token/create API may generate a refresh token. Therefore,
|
118
|
-
# callers of the API do not have to specify values of newly created
|
119
|
-
# refresh tokens. However, in some cases, for example, if you want
|
120
|
-
# to migrate existing refresh tokens from an old system to Authlete,
|
121
|
-
# you may want to specify values of refresh tokens. In such a case,
|
122
|
-
# you can specify the value of a newly created refresh token by passing
|
123
|
-
# a non-nil value as the value of refreshToken request parameter.
|
124
|
-
# The implementation of the /api/auth/token/create uses the value of
|
125
|
-
# the refreshToken request parameter instead of generating a new value
|
126
|
-
# when the request parameter holds a non-nil value.
|
127
|
-
# Note that if the hash value of the specified refresh token already
|
128
|
-
# exists in Authlete's database, the refresh token cannot be inserted
|
129
|
-
# and the /api/auth/token/create API will report an error.
|
130
|
-
# (String)
|
131
54
|
attr_accessor :refreshToken
|
132
55
|
alias_method :refresh_token, :refreshToken
|
133
56
|
alias_method :refresh_token=, :refreshToken=
|
134
57
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
INTEGER_ATTRIBUTES = ::Set.new([ :accessTokenDuration, :clientId, :refreshTokenDuration ])
|
139
|
-
|
140
|
-
# String attributes.
|
141
|
-
STRING_ATTRIBUTES = ::Set.new([ :accessToken, :refreshToken, :grantType, :subject, :clientIdAlias ])
|
142
|
-
|
143
|
-
# String array attributes.
|
144
|
-
STRING_ARRAY_ATTRIBUTES = ::Set.new([ :scopes ])
|
145
|
-
|
146
|
-
# Mapping from snake cases to camel cases.
|
147
|
-
SNAKE_TO_CAMEL = {
|
148
|
-
:access_token => :accessToken,
|
149
|
-
:access_token_duration => :accessTokenDuration,
|
150
|
-
:client_id => :clientId,
|
151
|
-
:client_id_alias => :clientIdAlias,
|
152
|
-
:grant_type => :grantType,
|
153
|
-
:refresh_token => :refreshToken,
|
154
|
-
:refresh_token_duration => :refreshTokenDuration
|
155
|
-
}
|
156
|
-
|
157
|
-
# The constructor which takes a hash that represents a JSON request to
|
158
|
-
# Authlete's /api/auth/token/create API.
|
159
|
-
def initialize(hash = nil)
|
160
|
-
# Set default values to integer attributes.
|
161
|
-
INTEGER_ATTRIBUTES.each do |attr|
|
162
|
-
send("#{attr}=", 0)
|
163
|
-
end
|
164
|
-
|
165
|
-
# Set default values to string attributes.
|
166
|
-
STRING_ATTRIBUTES.each do |attr|
|
167
|
-
send("#{attr}=", nil)
|
168
|
-
end
|
169
|
-
|
170
|
-
# Set default values to string array attributes.
|
171
|
-
STRING_ARRAY_ATTRIBUTES.each do |attr|
|
172
|
-
send("#{attr}=", nil)
|
173
|
-
end
|
58
|
+
attr_accessor :accessTokenPersistent
|
59
|
+
alias_method :access_token_persistent, :accessTokenPersistent
|
60
|
+
alias_method :access_token_persistent=, :accessTokenPersistent=
|
174
61
|
|
175
|
-
|
62
|
+
attr_accessor :certificateThumbprint
|
63
|
+
alias_method :certificate_thumbprint, :certificateThumbprint
|
64
|
+
alias_method :certificate_thumbprint=, :certificateThumbprint=
|
176
65
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
def authlete_model_convert_key(key)
|
182
|
-
key = key.to_sym
|
183
|
-
|
184
|
-
# Convert snakecase to camelcase, if necessary.
|
185
|
-
if SNAKE_TO_CAMEL.has_key?(key)
|
186
|
-
key = SNAKE_TO_CAMEL[key]
|
187
|
-
end
|
66
|
+
attr_accessor :dpopKeyThumbprint
|
67
|
+
alias_method :dpop_key_thumbprint, :dpopKeyThumbprint
|
68
|
+
alias_method :dpop_key_thumbprint=, :dpopKeyThumbprint=
|
188
69
|
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
def authlete_model_simple_attribute?(key)
|
193
|
-
INTEGER_ATTRIBUTES.include?(key) or
|
194
|
-
STRING_ATTRIBUTES.include?(key) or
|
195
|
-
STRING_ARRAY_ATTRIBUTES.include?(key)
|
196
|
-
end
|
197
|
-
|
198
|
-
def authlete_model_update(hash)
|
199
|
-
return if hash.nil?
|
200
|
-
|
201
|
-
hash.each do |key, value|
|
202
|
-
key = authlete_model_convert_key(key)
|
203
|
-
|
204
|
-
if authlete_model_simple_attribute?(key)
|
205
|
-
send("#{key}=", value)
|
206
|
-
elsif key == :properties
|
207
|
-
@properties = get_parsed_array(value) do |element|
|
208
|
-
Authlete::Model::Property.parse(element)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
70
|
+
private
|
212
71
|
|
213
|
-
|
72
|
+
def defaults
|
73
|
+
{
|
74
|
+
grantType: nil,
|
75
|
+
clientId: 0,
|
76
|
+
subject: nil,
|
77
|
+
scopes: nil,
|
78
|
+
accessTokenDuration: 0,
|
79
|
+
refreshTokenDuration: 0,
|
80
|
+
properties: nil,
|
81
|
+
clientIdAlias: nil,
|
82
|
+
accessToken: nil,
|
83
|
+
refreshToken: nil,
|
84
|
+
accessTokenPersistent: false,
|
85
|
+
certificateThumbprint: nil,
|
86
|
+
dpopKeyThumbprint: nil
|
87
|
+
}
|
214
88
|
end
|
215
89
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
90
|
+
def set_params(hash)
|
91
|
+
@grantType = hash[:grantType]
|
92
|
+
@clientId = hash[:clientId]
|
93
|
+
@subject = hash[:subject]
|
94
|
+
@scopes = hash[:scopes]
|
95
|
+
@accessTokenDuration = hash[:accessTokenDuration]
|
96
|
+
@refreshTokenDuration = hash[:refreshTokenDuration]
|
97
|
+
@properties = get_parsed_array(hash[:properties]) { |e| Authlete::Model::Property.parse(e) }
|
98
|
+
@clientIdAlias = hash[:clientIdAlias]
|
99
|
+
@accessToken = hash[:accessToken]
|
100
|
+
@refreshToken = hash[:refreshToken]
|
101
|
+
@accessTokenPersistent = hash[:accessTokenPersistent]
|
102
|
+
@certificateThumbprint = hash[:certificateThumbprint]
|
103
|
+
@dpopKeyThumbprint = hash[:dpopKeyThumbprint]
|
228
104
|
end
|
229
105
|
|
230
|
-
|
231
|
-
|
232
|
-
hash = {}
|
233
|
-
|
234
|
-
instance_variables.each do |var|
|
235
|
-
key = var.to_s.delete("@").to_sym
|
236
|
-
val = instance_variable_get(var)
|
106
|
+
def to_hash_value(key, var)
|
107
|
+
raw_val = instance_variable_get(var)
|
237
108
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
109
|
+
case key
|
110
|
+
when :properties
|
111
|
+
raw_val&.map { |e| e.to_hash }
|
112
|
+
else
|
113
|
+
raw_val
|
243
114
|
end
|
244
|
-
|
245
|
-
hash
|
246
115
|
end
|
247
116
|
end
|
248
117
|
end
|
249
118
|
end
|
250
|
-
end
|
119
|
+
end
|