Skip to content

Commit

Permalink
Add basic support for the new authentication protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
khaf committed May 10, 2022
1 parent 1f3e947 commit f8898ba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

All notable changes to this project will be documented in this file.

## [2.20.0] - 2020-11-08
## [2.20.1] - 2022-05-11

* **Improvements**
* Add basic support for the new authentication protocol.

## [2.20.0] - 2021-11-08

Notice: This version of the client only supports Aerospike Server v4.9 and later. Some features will work for the older server versions, but they are not tested, nor officially supported.

Expand Down
20 changes: 14 additions & 6 deletions lib/aerospike/command/admin_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ module Aerospike
#CREATE_ROLE = 8
QUERY_USERS = 9
#QUERY_ROLES = 10
LOGIN = 20

# Field IDs
USER = 0
PASSWORD = 1
OLD_PASSWORD = 2
CREDENTIAL = 3
ROLES = 10
USER = 0
PASSWORD = 1
OLD_PASSWORD = 2
CREDENTIAL = 3
CLEAR_PASSWORD = 4
ROLES = 10
#PRIVILEGES = 11

# Misc
Expand All @@ -60,14 +62,20 @@ def authenticate(conn, user, password)
conn.read(@data_buffer, HEADER_SIZE)

result = @data_buffer.read(RESULT_CODE)

# read the rest of the buffer
size = @data_buffer.read_int64(0)
length = (size & 0xFFFFFFFFFFFF) - HEADER_REMAINING
conn.read(@data_buffer, length)

raise Exceptions::Aerospike.new(result, "Authentication failed") if result != 0
ensure
Buffer.put(@data_buffer)
end
end

def set_authenticate(user, password)
write_header(AUTHENTICATE, 2)
write_header(LOGIN, 2)
write_field_str(USER, user)
write_field_bytes(CREDENTIAL, password)
write_size
Expand Down
2 changes: 1 addition & 1 deletion lib/aerospike/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
module Aerospike
VERSION = "2.20.0"
VERSION = "2.20.1"
end

0 comments on commit f8898ba

Please sign in to comment.