Skip to content

Commit

Permalink
Fix encodeBase64 for empty password or user in HTTP Basic Authentic…
Browse files Browse the repository at this point in the history
…ation (#4326)
  • Loading branch information
Saibamen committed Jan 6, 2024
1 parent f1e2ee7 commit 458cdf9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,12 @@ class Monitor extends BeanModel {
/**
* Encode user and password to Base64 encoding
* for HTTP "basic" auth, as per RFC-7617
* @param {string|null} user - The username (nullable if not changed by a user)
* @param {string|null} pass - The password (nullable if not changed by a user)
* @returns {string}
*/
encodeBase64(user, pass) {
return Buffer.from(user + ":" + pass).toString("base64");
return Buffer.from(`${user || ""}:${pass || ""}`).toString("base64");
}

/**
Expand Down

0 comments on commit 458cdf9

Please sign in to comment.