Skip to content

Commit 02a83c2

Browse files
committed
Allow authenticating with an empty password
1 parent 41d32c5 commit 02a83c2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tarantool.lua

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,19 @@ function _authenticate(self)
321321
if not self.user then
322322
return true
323323
end
324-
local step_1 = ngx.sha1_bin(self.password)
325-
local step_2 = ngx.sha1_bin(step_1)
326-
local step_3 = ngx.sha1_bin(self._salt .. step_2)
327-
local scramble = _xor(step_1, step_3)
328-
local response, err = self:_request({ [C.TYPE] = C.AUTH }, { [C.USER_NAME] = self.user , [C.TUPLE] = { "chap-sha1", scramble } })
324+
325+
local rbody = { [C.USER_NAME] = self.user, [C.TUPLE] = { } }
326+
327+
local password = self.password or ''
328+
if password ~= '' then
329+
local step_1 = ngx.sha1_bin(self.password)
330+
local step_2 = ngx.sha1_bin(step_1)
331+
local step_3 = ngx.sha1_bin(self._salt .. step_2)
332+
local scramble = _xor(step_1, step_3)
333+
rbody[C.TUPLE] = { "chap-sha1", scramble }
334+
end
335+
336+
local response, err = self:_request({ [C.TYPE] = C.AUTH }, rbody)
329337
if err then
330338
return nil, err
331339
elseif response and response.code ~= C.OK then

0 commit comments

Comments
 (0)