File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,13 @@ function parseServerFirstMessage(data) {
178178
179179function parseServerFinalMessage ( serverData ) {
180180 const attrPairs = parseAttributePairs ( serverData )
181+ const error = attrPairs . get ( 'e' )
181182 const serverSignature = attrPairs . get ( 'v' )
183+
184+ if ( error ) {
185+ throw new Error ( `SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${ error } "` )
186+ }
187+
182188 if ( ! serverSignature ) {
183189 throw new Error ( 'SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing' )
184190 } else if ( ! isBase64 ( serverSignature ) ) {
Original file line number Diff line number Diff line change @@ -284,6 +284,23 @@ suite.test('sasl/scram', function () {
284284 )
285285 } )
286286
287+ suite . test ( 'fails when server returns an error' , function ( ) {
288+ assert . throws (
289+ function ( ) {
290+ sasl . finalizeSession (
291+ {
292+ message : 'SASLResponse' ,
293+ serverSignature : 'abcd' ,
294+ } ,
295+ 'e=no-resources'
296+ )
297+ } ,
298+ {
299+ message : 'SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "no-resources"' ,
300+ }
301+ )
302+ } )
303+
287304 suite . test ( 'fails when server signature does not match' , function ( ) {
288305 assert . throws (
289306 function ( ) {
You can’t perform that action at this time.
0 commit comments