Skip to content

Commit f0e2113

Browse files
stevebioanu3990
authored andcommitted
Remove unnecessary top-level MD5 digester functions that cause an exception on FIPS-enabled systems when the www-authenticate module is loaded via require. The MD5 digester functions are already created on demand when using DIGEST authentication.
Use Buffer.from rather than deprecated new Buffer constructor form. Move the Parser_Authenticate_Info prototype statement to after the definition of the function. Add copyright to all the files.
1 parent 7eb9b92 commit f0e2113

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

lib/www-authenticate-patched/md5.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
var crypto= require('crypto')
2-
, md5sum = crypto.createHash('md5')
3-
;
1+
/*
2+
* www-authenticate
3+
* https://github.com/randymized/www-authenticate
4+
*
5+
* Copyright (c) 2013 Randy McLaughlin
6+
* Licensed under the MIT license.
7+
*/
8+
9+
/*
10+
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
11+
*/
12+
var crypto= require('crypto');
413

514
function md5(s) {
615
return crypto.createHash('md5').update(s).digest('hex');

lib/www-authenticate-patched/parsers.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* www-authenticate
3+
* https://github.com/randymized/www-authenticate
4+
*
5+
* Copyright (c) 2013 Randy McLaughlin
6+
* Licensed under the MIT license.
7+
*/
8+
9+
/*
10+
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
11+
*/
112
var ParseAuth= /(\w+)\s+(.*)/ // -> scheme, params
213
, Separators= /([",=])/
314
;
@@ -88,8 +99,6 @@ function Parse_WWW_Authenticate(to_parse)
8899
}
89100
}
90101

91-
Parse_Authentication_Info.prototype.parse_params= parse_params;
92-
93102
function Parse_Authentication_Info(to_parse)
94103
{
95104
this.scheme= 'Digest';
@@ -102,6 +111,7 @@ function Parse_Authentication_Info(to_parse)
102111
}
103112
}
104113

114+
Parse_Authentication_Info.prototype.parse_params= parse_params;
105115
Parse_WWW_Authenticate.prototype.parse_params= parse_params;
106116

107117
module.exports = {

lib/www-authenticate-patched/user-credentials.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* www-authenticate
3+
* https://github.com/randymized/www-authenticate
4+
*
5+
* Copyright (c) 2013 Randy McLaughlin
6+
* Licensed under the MIT license.
7+
*/
8+
9+
/*
10+
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
11+
*/
112
var md5= require('./md5');
213

314
/*
@@ -16,9 +27,9 @@ function user_credentials(username,password,options) {
1627
''
1728
:
1829
(!password && password !== '' ?
19-
new Buffer(username, "ascii").toString("base64")
30+
Buffer.from(username, "ascii").toString("base64")
2031
:
21-
new Buffer(username+':'+password, "ascii").toString("base64")
32+
Buffer.from(username+':'+password, "ascii").toString("base64")
2233
)
2334
function Credentials()
2435
{

lib/www-authenticate-patched/www-authenticate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* www-authenticate
43
* https://github.com/randymized/www-authenticate
@@ -7,10 +6,12 @@
76
* Licensed under the MIT license.
87
*/
98

9+
/*
10+
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
11+
*/
1012
'use strict';
1113

1214
var crypto= require('crypto')
13-
, md5sum = crypto.createHash('md5')
1415
, parsers= require('./parsers')
1516
, md5= require('./md5')
1617
, user_credentials= require('./user-credentials')

0 commit comments

Comments
 (0)