Skip to content

Commit 1324c35

Browse files
oleg-jukovecIvan Keberlein
and
Ivan Keberlein
committed
Fix authentication to Tarantool >= 2.10
The authentication method is checked on the server-side since Tarantool 2.11 [1]. In fact, this has been required before [2]. So we need to add the authorization method value into the AUTH_REQUEST. 1. tarantool/tarantool@b5754d3 2. https://www.tarantool.io/en/doc/1.10/dev_guide/internals_index/#authentication Co-authored-by: Ivan Keberlein <[email protected]>
1 parent edf8502 commit 1324c35

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/third_party/tp.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,9 @@ enum tp_request_type {
715715

716716
static const uint32_t SCRAMBLE_SIZE = 20;
717717

718+
static const char* CHAP_SHA1_AUTH_METHOD = "chap-sha1";
719+
static const uint32_t CHAP_SHA1_AUTH_METHOD_SIZE = 9;
720+
718721
/**
719722
* Receive greetings from the server.
720723
* Note, the input buffer is not copied,
@@ -1289,7 +1292,7 @@ tp_auth(struct tp *p, const char *salt_base64, const char *user, int ulen, const
12891292
mp_sizeof_uint(TP_TUPLE);
12901293
if (!nopass)
12911294
sz += mp_sizeof_array(2) +
1292-
mp_sizeof_str(0) +
1295+
mp_sizeof_str(CHAP_SHA1_AUTH_METHOD_SIZE) +
12931296
mp_sizeof_str(SCRAMBLE_SIZE);
12941297
else
12951298
sz += mp_sizeof_array(0);
@@ -1310,7 +1313,7 @@ tp_auth(struct tp *p, const char *salt_base64, const char *user, int ulen, const
13101313
h = mp_encode_uint(h, TP_TUPLE);
13111314
if (!nopass) {
13121315
h = mp_encode_array(h, 2);
1313-
h = mp_encode_str(h, 0, 0);
1316+
h = mp_encode_str(h, CHAP_SHA1_AUTH_METHOD, CHAP_SHA1_AUTH_METHOD_SIZE);
13141317

13151318
// char salt[64];
13161319
zend_string *salt = NULL;

test/CreateTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public function test_06_bad_credentials() {
107107
$this->assertTrue($c->ping());
108108

109109
$this->expectException(TarantoolClientError::class);
110-
$this->expectExceptionMessage(
111-
'Incorrect password supplied for user');
110+
$this->expectExceptionMessageMatches(
111+
'/(Incorrect password supplied for user)|(User not found or supplied credentials are invalid)/');
112112
$c->authenticate('test', 'bad_password');
113113
}
114114

@@ -118,8 +118,8 @@ public function test_07_bad_guest_credentials() {
118118
$this->assertTrue($c->ping());
119119

120120
$this->expectException(TarantoolClientError::class);
121-
$this->expectExceptionMessage(
122-
'Incorrect password supplied for user');
121+
$this->expectExceptionMessageMatches(
122+
'/(Incorrect password supplied for user)|(User not found or supplied credentials are invalid)/');
123123
$c->authenticate('guest', 'guest');
124124
}
125125

0 commit comments

Comments
 (0)