aerospike 2.20.1 → 2.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5453ee9475d4868e6b65ed5a13868dac07e0628538330da6b8f6f1a1a65624c7
4
- data.tar.gz: 74044cf1e3c30af803c2d04e7e17989cc49e699b229c1cd08b0cfb384ee004a4
3
+ metadata.gz: 2ad4dc9000e94d5dc8b3c4404e2b68907ba935c196e4061a843f49ec8ad54378
4
+ data.tar.gz: b55b74f657f46946eccd2ea4005075424234c5d12fa5a9bf77416870c2246928
5
5
  SHA512:
6
- metadata.gz: aea8982415b6f606822ab4648dc48fea6f13ca1984eb7f0ba7a1708da03a975dbd484aeb206ad3472af1c867f40623a6db4cb9fd35d80b0b65f54dfc4f10a059
7
- data.tar.gz: bab0149d85d4b90232bc2a9fad68aeda837b175ea981d671690cddf26e7713d5d8c7ef732abd2f1445e8bf880fb595f1b9aafd9b1b1028dd7c0ada94d70ccc97
6
+ metadata.gz: 37a3fb668569cbe8ff16318847cd99588f7d54afd342f3d45e397bcf2a241d44c7b1f3f5b2cfe6d98978b65d0babf812d6d51bb5051d9cc6a1aef43845e48c65
7
+ data.tar.gz: 3c13ca332594f6edc7cafb4eb68aa996afca8d09436053c31f0faf97b3005f011fa97afeb037aa17bc3a0bc9fcb48cfdad22a20639860dada568433055d47d09
data/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.22.0] 2022-07-14
6
+
7
+ * **Fixes**
8
+ * [CLIENT-1785] Fix Client#read_users to avoid error. PR #112 Thanks to [Dotan Mor](https://github.com/dotan-mor)
9
+ * [CLIENT-1787] Support multiple DNS IPs during connection.
10
+ * [CLIENT-1789] Authentication Retry fails in certain conditions.
11
+
12
+ ## [2.21.1] - 2022-06-21
13
+
14
+ This s hotfix release. It is recommended to upgrade your client if you use authentication.
15
+
16
+ * **Bug Fixes**
17
+ * Fix called function name in Authenticate.
18
+
19
+ ## [2.21.0] - 2022-06-07
20
+
21
+ * **New Features**
22
+ * Add support for new user management features. Adds `Client#query_role`, `Client#query_roles`, `Client#create_role`, `Client#drop_role`, `Client#grant_privileges`, `Client#revoke_privileges`. Adds the 'Role' class. Adds `UserRoles#read_info`, `UserRoles#write_info`, `UserRoles#conns_in_use` to the `UserRoles` class.
23
+
24
+ * **Improvements**
25
+ * Do not run PredExp tests for server v6+.
26
+
5
27
  ## [2.20.1] - 2022-05-11
6
28
 
7
29
  * **Improvements**
@@ -764,7 +764,7 @@ module Aerospike
764
764
  # before sending to server.
765
765
  def create_user(user, password, roles, options = nil)
766
766
  policy = create_policy(options, AdminPolicy, default_admin_policy)
767
- hash = AdminCommand.hash_password(password)
767
+ hash = LoginCommand.hash_password(password)
768
768
  command = AdminCommand.new
769
769
  command.create_user(@cluster, policy, user, hash, roles)
770
770
  end
@@ -781,7 +781,7 @@ module Aerospike
781
781
  raise Aerospike::Exceptions::Aerospike.new(INVALID_USER) unless @cluster.user && @cluster.user != ""
782
782
  policy = create_policy(options, AdminPolicy, default_admin_policy)
783
783
 
784
- hash = AdminCommand.hash_password(password)
784
+ hash = LoginCommand.hash_password(password)
785
785
  command = AdminCommand.new
786
786
 
787
787
  if user == @cluster.user
@@ -823,6 +823,50 @@ module Aerospike
823
823
  command.query_users(@cluster, policy)
824
824
  end
825
825
 
826
+ # Retrieve privileges for a given role.
827
+ def query_role(role, options = nil)
828
+ policy = create_policy(options, AdminPolicy, default_admin_policy)
829
+ command = AdminCommand.new
830
+ command.query_role(@cluster, policy, role)
831
+ end
832
+
833
+ # Retrieve all roles and their privileges.
834
+ def query_roles(options = nil)
835
+ policy = create_policy(options, AdminPolicy, default_admin_policy)
836
+ command = AdminCommand.new
837
+ command.query_roles(@cluster, policy)
838
+ end
839
+
840
+ # Create a user-defined role.
841
+ # Quotas require server security configuration "enable-quotas" to be set to true.
842
+ # Pass 0 for quota values for no limit.
843
+ def create_role(role_name, privileges = [], allowlist = [], read_quota = 0, write_quota = 0, options = nil)
844
+ policy = create_policy(options, AdminPolicy, default_admin_policy)
845
+ command = AdminCommand.new
846
+ command.create_role(@cluster, policy, role_name, privileges, allowlist, read_quota, write_quota)
847
+ end
848
+
849
+ # Remove a user-defined role.
850
+ def drop_role(role_name, options = nil)
851
+ policy = create_policy(options, AdminPolicy, default_admin_policy)
852
+ command = AdminCommand.new
853
+ command.drop_role(@cluster, policy, role_name)
854
+ end
855
+
856
+ # Grant privileges to a user-defined role.
857
+ def grant_privileges(role_name, privileges, options = nil)
858
+ policy = create_policy(options, AdminPolicy, default_admin_policy)
859
+ command = AdminCommand.new
860
+ command.grant_privileges(@cluster, policy, role_name, privileges)
861
+ end
862
+
863
+ # Revoke privileges from a user-defined role.
864
+ def revoke_privileges(role_name, privileges, options = nil)
865
+ policy = create_policy(options, AdminPolicy, default_admin_policy)
866
+ command = AdminCommand.new
867
+ command.revoke_privileges(@cluster, policy, role_name, privileges)
868
+ end
869
+
826
870
  private
827
871
 
828
872
  def set_default_policies(policies)
@@ -32,7 +32,7 @@ module Aerospike
32
32
  ).tap do |conn|
33
33
  if cluster.credentials_given?
34
34
  # Authenticate will raise and close connection if invalid credentials
35
- Connection::Authenticate.(conn, cluster.user, cluster.password)
35
+ Connection::AuthenticateNew.(conn, cluster)
36
36
  end
37
37
  end
38
38
  end
@@ -27,9 +27,12 @@ module Aerospike
27
27
  attr_reader :features, :tls_options
28
28
  attr_reader :cluster_id, :aliases
29
29
  attr_reader :cluster_name
30
+ attr_reader :client_policy
30
31
  attr_accessor :rack_aware, :rack_id
32
+ attr_accessor :session_token, :session_expiration
31
33
 
32
34
  def initialize(policy, hosts)
35
+ @client_policy = policy
33
36
  @cluster_seeds = hosts
34
37
  @fail_if_not_connected = policy.fail_if_not_connected
35
38
  @connection_queue_size = policy.connection_queue_size
@@ -56,7 +59,7 @@ module Aerospike
56
59
  # setup auth info for cluster
57
60
  if policy.requires_authentication
58
61
  @user = policy.user
59
- @password = AdminCommand.hash_password(policy.password)
62
+ @password = LoginCommand.hash_password(policy.password)
60
63
  end
61
64
 
62
65
  initialize_tls_host_names(hosts) if tls_enabled?
@@ -78,6 +81,15 @@ module Aerospike
78
81
  !(@user.nil? || @user.empty?)
79
82
  end
80
83
 
84
+ def session_valid?
85
+ @session_token && @session_expiration && @session_expiration.to_i < Time.now.to_i
86
+ end
87
+
88
+ def reset_session_info
89
+ @session_token = nil
90
+ @session_expiration = nil
91
+ end
92
+
81
93
  def tls_enabled?
82
94
  !tls_options.nil? && tls_options[:enable] != false
83
95
  end
@@ -436,6 +448,7 @@ module Aerospike
436
448
  cluster_config_changed = true
437
449
  end
438
450
 
451
+
439
452
  cluster_config_changed
440
453
  end
441
454
 
@@ -450,7 +463,7 @@ module Aerospike
450
463
  count = -1
451
464
  done = false
452
465
 
453
- # will run until the cluster is stablized
466
+ # will run until the cluster is stabilized
454
467
  thr = Thread.new do
455
468
  loop do
456
469
  tend
@@ -462,14 +475,17 @@ module Aerospike
462
475
  # Break if timed out
463
476
  break if done
464
477
 
465
- sleep(0.001) # sleep for a milisecond
478
+ sleep(0.001) # sleep for a millisecond
466
479
 
467
480
  count = nodes.length
468
481
  end
469
482
  end
470
483
 
471
484
  # wait for the thread to finish or timeout
472
- thr.join(@connection_timeout)
485
+ # This will give the client up to 10 times the timeout duration to find
486
+ # a host and connect successfully eventually, in case the DNS
487
+ # returns multiple IPs and some of them are not reachable.
488
+ thr.join(@connection_timeout * 10)
473
489
  done = true
474
490
  sleep(0.001)
475
491
  thr.kill if thr.alive?