@@ -1165,9 +1165,6 @@ public function authXOAuth2($uid, $token, $authz, $conn)
1165
1165
return true ;
1166
1166
}
1167
1167
1168
-
1169
-
1170
-
1171
1168
/**
1172
1169
* Authenticates the user using the SCRAM-SHA-1 method.
1173
1170
*
@@ -1279,23 +1276,48 @@ protected function authScramSHA($uid, $pwd, $authz = '')
1279
1276
}
1280
1277
1281
1278
$ auth_sasl = new Auth_SASL ;
1282
- $ challenge = base64_decode ($ this ->arguments [0 ]);
1283
1279
$ cram = $ auth_sasl ->factory ($ this ->scram_sha_hash_algorithm );
1284
- $ auth_str = base64_encode ($ cram ->getResponse ($ uid , $ pwd, $ challenge ));
1280
+ $ auth_str = base64_encode ($ cram ->getResponse ($ uid , $ pwd ));
1285
1281
1282
+ /* Step 1: Send first authentication request */
1286
1283
if (PEAR ::isError ($ error = $ this ->put ($ auth_str ))) {
1287
1284
return $ error ;
1288
1285
}
1289
1286
1290
- /* 235: Authentication successful */
1291
- if (PEAR ::isError ($ error = $ this ->parseResponse (235 ))) {
1287
+ /* 334: Continue authentication request with password salt */
1288
+ if (PEAR ::isError ($ error = $ this ->parseResponse (334 ))) {
1292
1289
return $ error ;
1293
1290
}
1294
- }
1295
1291
1292
+ $ challenge = base64_decode ($ this ->arguments [0 ]);
1293
+ $ auth_str = base64_encode ($ cram ->getResponse ($ uid , $ pwd , $ challenge ));
1296
1294
1295
+ /* Step 2: Send salted authentication request */
1296
+ if (PEAR ::isError ($ error = $ this ->put ($ auth_str ))) {
1297
+ return $ error ;
1298
+ }
1297
1299
1300
+ /* 334: Continue authentication request with password salt */
1301
+ if (PEAR ::isError ($ error = $ this ->parseResponse (334 ))) {
1302
+ return $ error ;
1303
+ }
1298
1304
1305
+ /* Verify server signature */
1306
+ $ verification = $ cram ->processOutcome (base64_decode ($ this ->arguments [0 ]));
1307
+ if ($ verification == false ) {
1308
+ return PEAR ::raiseError ("SCRAM Server verification on step 3 not successful " );
1309
+ }
1310
+
1311
+ /* Step 3: Send a request to acknowledge verification */
1312
+ if (PEAR ::isError ($ error = $ this ->put ("NOOP " ))) {
1313
+ return $ error ;
1314
+ }
1315
+
1316
+ /* 235: Authentication successful */
1317
+ if (PEAR ::isError ($ error = $ this ->parseResponse (235 ))) {
1318
+ return $ error ;
1319
+ }
1320
+ }
1299
1321
1300
1322
/**
1301
1323
* Send the HELO command.
0 commit comments