authlete 1.0.18 → 1.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,6 @@ module Authlete
22
22
  module Model
23
23
  class ClientExtension < Authlete::Model::Hashable
24
24
  include Authlete::Utility
25
-
26
25
  # The set of scopes that a client application is allowed to request.
27
26
  # (String array)
28
27
  attr_accessor :requestableScopes
@@ -36,8 +35,25 @@ module Authlete
36
35
  alias_method :requestable_scopes_enabled, :requestableScopesEnabled
37
36
  alias_method :requestable_scopes_enabled=, :requestableScopesEnabled=
38
37
 
38
+ # The duration of access tokens in seconds that are issued to a client.
39
+ # (Integer)
40
+ attr_accessor :accessTokenDuration
41
+ alias_method :access_token_duration, :accessTokenDuration
42
+ alias_method :access_token_duration=, :accessTokenDuration=
43
+
44
+ # The duration of refresh tokens in seconds that are issued to a client.
45
+ # (Integer)
46
+ attr_accessor :refreshTokenDuration
47
+ alias_method :refresh_token_duration, :refreshTokenDuration
48
+ alias_method :refresh_token_duration=, :refreshTokenDuration=
49
+
39
50
  private
40
51
 
52
+ # Integer attributes.
53
+ INTEGER_ATTRIBUTES = ::Set.new([
54
+ :accessTokenDuration, :refreshTokenDuration
55
+ ])
56
+
41
57
  # Boolean attributes.
42
58
  BOOLEAN_ATTRIBUTES = ::Set.new([
43
59
  :requestableScopesEnabled
@@ -51,11 +67,18 @@ module Authlete
51
67
  # Mapping from snake cases to camel cases.
52
68
  SNAKE_TO_CAMEL = {
53
69
  :requestable_scopes => :requestableScopes,
54
- :requestable_scopes_enabled => :requestableScopesEnabled
70
+ :requestable_scopes_enabled => :requestableScopesEnabled,
71
+ :access_token_duration => :accessTokenDuration,
72
+ :refresh_token_duration => :refreshTokenDuration
55
73
  }
56
74
 
57
75
  # The constructor
58
76
  def initialize(hash = nil)
77
+ # Set default values to integer attributes.
78
+ INTEGER_ATTRIBUTES.each do |attr|
79
+ send("#{attr}=", 0)
80
+ end
81
+
59
82
  # Set default values to boolean attributes.
60
83
  BOOLEAN_ATTRIBUTES.each do |attr|
61
84
  send("#{attr}=", false)
@@ -82,6 +105,7 @@ module Authlete
82
105
  end
83
106
 
84
107
  def authlete_model_simple_attribute?(key)
108
+ INTEGER_ATTRIBUTES.include?(key) or
85
109
  BOOLEAN_ATTRIBUTES.include?(key) or
86
110
  STRING_ARRAY_ATTRIBUTES.include?(key)
87
111
  end
@@ -371,6 +371,18 @@ module Authlete
371
371
  alias_method :authorization_data_types, :authorizationDataTypes
372
372
  alias_method :authorization_data_types=, :authorizationDataTypes=
373
373
 
374
+ # Flag of whether this client is required to use the pushed authorization
375
+ # request endpoint. (Boolean)
376
+ attr_accessor :parRequired
377
+ alias_method :par_required, :parRequired
378
+ alias_method :par_required=, :parRequired=
379
+
380
+ # Flag of whether authorization requests from this client must always
381
+ # contain a request object. (Boolean)
382
+ attr_accessor :requestObjectRequired
383
+ alias_method :request_object_required, :requestObjectRequired
384
+ alias_method :request_object_required=, :requestObjectRequired=
385
+
374
386
  private
375
387
 
376
388
  # Integer attributes.
@@ -381,7 +393,7 @@ module Authlete
381
393
  # Boolean attributes.
382
394
  BOOLEAN_ATTRIBUTES = ::Set.new([
383
395
  :authTimeRequired, :clientIdAliasEnabled, :tlsClientCertificateBoundAccessTokens,
384
- :bcUserCodeRequired, :dynamicallyRegistered
396
+ :bcUserCodeRequired, :dynamicallyRegistered, :parRequired, :requestObjectRequired
385
397
  ])
386
398
 
387
399
  # String attributes.
@@ -411,64 +423,66 @@ module Authlete
411
423
 
412
424
  # Mapping from snake cases to camel cases.
413
425
  SNAKE_TO_CAMEL = {
414
- :service_number => :serviceNumber,
415
- :client_id => :clientId,
416
- :client_id_alias => :clientIdAlias,
417
- :client_id_alias_enabled => :clientIdAliasEnabled,
418
- :client_secret => :clientSecret,
419
- :client_type => :clientType,
420
- :redirect_uris => :redirectUris,
421
- :response_types => :responseTypes,
422
- :grant_types => :grantTypes,
423
- :application_type => :applicationType,
424
- :client_name => :clientName,
425
- :client_names => :clientNames,
426
- :logo_uri => :logoUri,
427
- :logo_uris => :logoUris,
428
- :client_uri => :clientUri,
429
- :client_uris => :clientUris,
430
- :policy_uri => :policyUri,
431
- :policy_uris => :policyUris,
432
- :tos_uri => :tosUri,
433
- :tos_uris => :tosUris,
434
- :jwks_uri => :jwksUri,
435
- :sector_identifier => :sectorIdentifier,
436
- :subject_type => :subjectType,
437
- :id_token_sign_alg => :idTokenSignAlg,
438
- :id_token_encryption_alg => :idTokenEncryptionAlg,
439
- :id_token_encryption_enc => :idTokenEncryptionEnc,
440
- :user_info_sign_alg => :userInfoSignAlg,
441
- :user_info_encryption_alg => :userInfoEncryptionAlg,
442
- :user_info_encryption_enc => :userInfoEncryptionEnc,
443
- :request_sign_alg => :requestSignAlg,
444
- :request_encryption_alg => :requestEncryptionAlg,
445
- :request_encryption_enc => :requestEncryptionEnc,
446
- :token_auth_method => :tokenAuthMethod,
447
- :token_auth_sign_alg => :tokenAuthSignAlg,
448
- :default_max_age => :defaultMaxAge,
449
- :default_acrs => :defaultAcrs,
450
- :auth_time_required => :authTimeRequired,
451
- :login_uri => :loginUri,
452
- :request_uris => :requestUris,
453
- :created_at => :createdAt,
454
- :modified_at => :modifiedAt,
455
- :tls_client_auth_subject_dn => :tlsClientAuthSubjectDn,
456
- :tls_client_certificate_bound_access_tokens => :tlsClientCertificateBoundAccessTokens,
457
- :self_signed_certificate_key_id => :selfSignedCertificateKeyId,
458
- :authorization_sign_alg => :authorizationSignAlg,
459
- :authorization_encryption_alg => :authorizationEncryptionAlg,
460
- :authorization_encryption_enc => :authorizationEncryptionEnc,
461
- :bc_delivery_mode => :bcDeliveryMode,
462
- :bc_notification_endpoint => :bcNotificationEndpoint,
463
- :bc_request_sign_alg => :bcRequestSignAlg,
464
- :bc_user_code_required => :bcUserCodeRequired,
465
- :dynamically_registered => :dynamicallyRegistered,
466
- :tls_client_auth_san_email => :tlsClientAuthSanEmail,
467
- :tls_client_auth_san_ip => :tlsClientAuthSanIp,
468
- :tls_client_auth_san_uri => :tlsClientAuthSanUri,
469
- :tls_client_auth_san_dns => :tlsClientAuthSanDns,
470
- :sector_identifier_uri => :sectorIdentifierUri,
471
- :authorization_data_types => :authorizationDataTypes
426
+ :service_number => :serviceNumber,
427
+ :client_id => :clientId,
428
+ :client_id_alias => :clientIdAlias,
429
+ :client_id_alias_enabled => :clientIdAliasEnabled,
430
+ :client_secret => :clientSecret,
431
+ :client_type => :clientType,
432
+ :redirect_uris => :redirectUris,
433
+ :response_types => :responseTypes,
434
+ :grant_types => :grantTypes,
435
+ :application_type => :applicationType,
436
+ :client_name => :clientName,
437
+ :client_names => :clientNames,
438
+ :logo_uri => :logoUri,
439
+ :logo_uris => :logoUris,
440
+ :client_uri => :clientUri,
441
+ :client_uris => :clientUris,
442
+ :policy_uri => :policyUri,
443
+ :policy_uris => :policyUris,
444
+ :tos_uri => :tosUri,
445
+ :tos_uris => :tosUris,
446
+ :jwks_uri => :jwksUri,
447
+ :sector_identifier => :sectorIdentifier,
448
+ :subject_type => :subjectType,
449
+ :id_token_sign_alg => :idTokenSignAlg,
450
+ :id_token_encryption_alg => :idTokenEncryptionAlg,
451
+ :id_token_encryption_enc => :idTokenEncryptionEnc,
452
+ :user_info_sign_alg => :userInfoSignAlg,
453
+ :user_info_encryption_alg => :userInfoEncryptionAlg,
454
+ :user_info_encryption_enc => :userInfoEncryptionEnc,
455
+ :request_sign_alg => :requestSignAlg,
456
+ :request_encryption_alg => :requestEncryptionAlg,
457
+ :request_encryption_enc => :requestEncryptionEnc,
458
+ :token_auth_method => :tokenAuthMethod,
459
+ :token_auth_sign_alg => :tokenAuthSignAlg,
460
+ :default_max_age => :defaultMaxAge,
461
+ :default_acrs => :defaultAcrs,
462
+ :auth_time_required => :authTimeRequired,
463
+ :login_uri => :loginUri,
464
+ :request_uris => :requestUris,
465
+ :created_at => :createdAt,
466
+ :modified_at => :modifiedAt,
467
+ :tls_client_auth_subject_dn => :tlsClientAuthSubjectDn,
468
+ :tls_client_certificate_bound_access_tokens => :tlsClientCertificateBoundAccessTokens,
469
+ :self_signed_certificate_key_id => :selfSignedCertificateKeyId,
470
+ :authorization_sign_alg => :authorizationSignAlg,
471
+ :authorization_encryption_alg => :authorizationEncryptionAlg,
472
+ :authorization_encryption_enc => :authorizationEncryptionEnc,
473
+ :bc_delivery_mode => :bcDeliveryMode,
474
+ :bc_notification_endpoint => :bcNotificationEndpoint,
475
+ :bc_request_sign_alg => :bcRequestSignAlg,
476
+ :bc_user_code_required => :bcUserCodeRequired,
477
+ :dynamically_registered => :dynamicallyRegistered,
478
+ :tls_client_auth_san_email => :tlsClientAuthSanEmail,
479
+ :tls_client_auth_san_ip => :tlsClientAuthSanIp,
480
+ :tls_client_auth_san_uri => :tlsClientAuthSanUri,
481
+ :tls_client_auth_san_dns => :tlsClientAuthSanDns,
482
+ :sector_identifier_uri => :sectorIdentifierUri,
483
+ :authorization_data_types => :authorizationDataTypes,
484
+ :par_required => :parRequired,
485
+ :request_object_required => :requestObjectRequired
472
486
  }
473
487
 
474
488
  # The constructor
@@ -1,158 +1,158 @@
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 Scope < Authlete::Model::Hashable
24
- include Authlete::Utility
25
- # The attributes of this scopes. (Pair array)
26
- attr_accessor :attributes
27
-
28
- # The description about this scope. (String)
29
- attr_accessor :description
30
-
31
- # The descriptions about this scope with language tags.
32
- # (TaggedValue array)
33
- attr_accessor :descriptions
34
-
35
- # The name of this scope. (String)
36
- attr_accessor :name
37
-
38
- # The flag to indicate whether this scope is included in the
39
- # default scope set. (Boolean)
40
- attr_accessor :defaultEntry
41
- alias_method :default_entry, :defaultEntry
42
- alias_method :default_entry=, :defaultEntry=
43
-
44
- private
45
-
46
- # Boolean attributes.
47
- BOOLEAN_ATTRIBUTES = ::Set.new([ :defaultEntry ])
48
-
49
- # String attributes.
50
- STRING_ATTRIBUTES = ::Set.new([ :description, :name ])
51
-
52
- # Tagged value array attributes.
53
- TAGGED_VALUE_ARRAY_ATTRIBUTES = ::Set.new([ :descriptions ])
54
-
55
- # Mapping from snake cases to camel cases.
56
- SNAKE_TO_CAMEL = { :default_entry => :defaultEntry }
57
-
58
- # The constructor
59
- def initialize(hash = nil)
60
- # Set default values to boolean attributes.
61
- BOOLEAN_ATTRIBUTES.each do |attr|
62
- send("#{attr}=", false)
63
- end
64
-
65
- # Set default values to string attributes.
66
- STRING_ATTRIBUTES.each do |attr|
67
- send("#{attr}=", nil)
68
- end
69
-
70
- # Set default values to tagged value array attributes.
71
- TAGGED_VALUE_ARRAY_ATTRIBUTES.each do |attr|
72
- send("#{attr}=", nil)
73
- end
74
-
75
- # Set attribute values using the given hash.
76
- authlete_model_update(hash)
77
- end
78
-
79
- def authlete_model_convert_key(key)
80
- key = key.to_sym
81
-
82
- # Convert snakecase to camelcase, if necessary.
83
- if SNAKE_TO_CAMEL.has_key?(key)
84
- key = SNAKE_TO_CAMEL[key]
85
- end
86
-
87
- key
88
- end
89
-
90
- def authlete_model_simple_attribute?(key)
91
- BOOLEAN_ATTRIBUTES.include?(key) or
92
- STRING_ATTRIBUTES.include?(key)
93
- end
94
-
95
- def authlete_model_update(hash)
96
- return if hash.nil?
97
-
98
- hash.each do |key, value|
99
- key = authlete_model_convert_key(key)
100
-
101
- if authlete_model_simple_attribute?(key)
102
- send("#{key}=", value)
103
- elsif TAGGED_VALUE_ARRAY_ATTRIBUTES.include?(key)
104
- # Get an array consisting of "TaggedValue" objects.
105
- parsed = get_parsed_array(value) do |element|
106
- Authlete::Model::TaggedValue.parse(element)
107
- end
108
-
109
- send("#{key}=", parsed)
110
- elsif key == :attributes
111
- @attributes = get_parsed_array(value) do |element|
112
- Authlete::Model::Pair.parse(element)
113
- end
114
- end
115
- end
116
-
117
- self
118
- end
119
-
120
- public
121
-
122
- # Construct an instance from the given hash.
123
- #
124
- # If the given argument is nil or is not a Hash, nil is returned.
125
- # Otherwise, Scope.new(hash) is returned.
126
- def self.parse(hash)
127
- if hash.nil? or (hash.kind_of?(Hash) == false)
128
- return nil
129
- end
130
-
131
- Authlete::Model::Scope.new(hash)
132
- end
133
-
134
- # Set attribute values using the given hash.
135
- def update(hash)
136
- authlete_model_update(hash)
137
- end
138
-
139
- # Convert this object into a hash.
140
- def to_hash
141
- hash = {}
142
-
143
- instance_variables.each do |var|
144
- key = var.to_s.delete("@").to_sym
145
- val = instance_variable_get(var)
146
-
147
- if authlete_model_simple_attribute?(key) or val.nil?
148
- hash[key] = val
149
- elsif key == :attributes or key == :descriptions
150
- hash[key] = val.map { |element| element.to_hash }
151
- end
152
- end
153
-
154
- hash
155
- end
156
- end
157
- 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 Scope < Authlete::Model::Hashable
24
+ include Authlete::Utility
25
+ # The attributes of this scopes. (Pair array)
26
+ attr_accessor :attributes
27
+
28
+ # The description about this scope. (String)
29
+ attr_accessor :description
30
+
31
+ # The descriptions about this scope with language tags.
32
+ # (TaggedValue array)
33
+ attr_accessor :descriptions
34
+
35
+ # The name of this scope. (String)
36
+ attr_accessor :name
37
+
38
+ # The flag to indicate whether this scope is included in the
39
+ # default scope set. (Boolean)
40
+ attr_accessor :defaultEntry
41
+ alias_method :default_entry, :defaultEntry
42
+ alias_method :default_entry=, :defaultEntry=
43
+
44
+ private
45
+
46
+ # Boolean attributes.
47
+ BOOLEAN_ATTRIBUTES = ::Set.new([ :defaultEntry ])
48
+
49
+ # String attributes.
50
+ STRING_ATTRIBUTES = ::Set.new([ :description, :name ])
51
+
52
+ # Tagged value array attributes.
53
+ TAGGED_VALUE_ARRAY_ATTRIBUTES = ::Set.new([ :descriptions ])
54
+
55
+ # Mapping from snake cases to camel cases.
56
+ SNAKE_TO_CAMEL = { :default_entry => :defaultEntry }
57
+
58
+ # The constructor
59
+ def initialize(hash = nil)
60
+ # Set default values to boolean attributes.
61
+ BOOLEAN_ATTRIBUTES.each do |attr|
62
+ send("#{attr}=", false)
63
+ end
64
+
65
+ # Set default values to string attributes.
66
+ STRING_ATTRIBUTES.each do |attr|
67
+ send("#{attr}=", nil)
68
+ end
69
+
70
+ # Set default values to tagged value array attributes.
71
+ TAGGED_VALUE_ARRAY_ATTRIBUTES.each do |attr|
72
+ send("#{attr}=", nil)
73
+ end
74
+
75
+ # Set attribute values using the given hash.
76
+ authlete_model_update(hash)
77
+ end
78
+
79
+ def authlete_model_convert_key(key)
80
+ key = key.to_sym
81
+
82
+ # Convert snakecase to camelcase, if necessary.
83
+ if SNAKE_TO_CAMEL.has_key?(key)
84
+ key = SNAKE_TO_CAMEL[key]
85
+ end
86
+
87
+ key
88
+ end
89
+
90
+ def authlete_model_simple_attribute?(key)
91
+ BOOLEAN_ATTRIBUTES.include?(key) or
92
+ STRING_ATTRIBUTES.include?(key)
93
+ end
94
+
95
+ def authlete_model_update(hash)
96
+ return if hash.nil?
97
+
98
+ hash.each do |key, value|
99
+ key = authlete_model_convert_key(key)
100
+
101
+ if authlete_model_simple_attribute?(key)
102
+ send("#{key}=", value)
103
+ elsif TAGGED_VALUE_ARRAY_ATTRIBUTES.include?(key)
104
+ # Get an array consisting of "TaggedValue" objects.
105
+ parsed = get_parsed_array(value) do |element|
106
+ Authlete::Model::TaggedValue.parse(element)
107
+ end
108
+
109
+ send("#{key}=", parsed)
110
+ elsif key == :attributes
111
+ @attributes = get_parsed_array(value) do |element|
112
+ Authlete::Model::Pair.parse(element)
113
+ end
114
+ end
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ public
121
+
122
+ # Construct an instance from the given hash.
123
+ #
124
+ # If the given argument is nil or is not a Hash, nil is returned.
125
+ # Otherwise, Scope.new(hash) is returned.
126
+ def self.parse(hash)
127
+ if hash.nil? or (hash.kind_of?(Hash) == false)
128
+ return nil
129
+ end
130
+
131
+ Authlete::Model::Scope.new(hash)
132
+ end
133
+
134
+ # Set attribute values using the given hash.
135
+ def update(hash)
136
+ authlete_model_update(hash)
137
+ end
138
+
139
+ # Convert this object into a hash.
140
+ def to_hash
141
+ hash = {}
142
+
143
+ instance_variables.each do |var|
144
+ key = var.to_s.delete("@").to_sym
145
+ val = instance_variable_get(var)
146
+
147
+ if authlete_model_simple_attribute?(key) or val.nil?
148
+ hash[key] = val
149
+ elsif key == :attributes or key == :descriptions
150
+ hash[key] = val.map { |element| element.to_hash }
151
+ end
152
+ end
153
+
154
+ hash
155
+ end
156
+ end
157
+ end
158
158
  end