aerospike 2.20.1 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/aerospike/client.rb +46 -2
- data/lib/aerospike/cluster/create_connection.rb +1 -1
- data/lib/aerospike/cluster.rb +20 -4
- data/lib/aerospike/command/admin_command.rb +362 -54
- data/lib/aerospike/command/command.rb +0 -6
- data/lib/aerospike/command/login_command.rb +164 -0
- data/lib/aerospike/connection/authenticate.rb +36 -3
- data/lib/aerospike/node_validator.rb +6 -1
- data/lib/aerospike/policy/auth_mode.rb +36 -0
- data/lib/aerospike/policy/client_policy.rb +4 -1
- data/lib/aerospike/privilege.rb +133 -0
- data/lib/aerospike/result_code.rb +4 -4
- data/lib/aerospike/role.rb +55 -0
- data/lib/aerospike/user_role.rb +25 -0
- data/lib/aerospike/utils/buffer.rb +21 -0
- data/lib/aerospike/version.rb +1 -1
- data/lib/aerospike.rb +4 -0
- metadata +6 -3
- data/lib/aerospike/command/roles.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ad4dc9000e94d5dc8b3c4404e2b68907ba935c196e4061a843f49ec8ad54378
|
4
|
+
data.tar.gz: b55b74f657f46946eccd2ea4005075424234c5d12fa5a9bf77416870c2246928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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**
|
data/lib/aerospike/client.rb
CHANGED
@@ -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 =
|
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 =
|
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::
|
35
|
+
Connection::AuthenticateNew.(conn, cluster)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/aerospike/cluster.rb
CHANGED
@@ -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 =
|
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
|
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
|
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
|
-
|
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?
|