You've already forked uptime-kuma
mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-27 00:51:30 +02:00
Switched to crypto.randomBytes fpr key generation
Keys are now 32 bytes long encoded in a URL safe base64 string Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
@ -17,7 +17,7 @@ module.exports.apiKeySocketHandler = (socket) => {
|
||||
socket.on("addAPIKey", async (key, callback) => {
|
||||
try {
|
||||
checkLogin(socket);
|
||||
let clearKey = crypto.randomUUID();
|
||||
let clearKey = crypto.randomBytes(32).toString("base64url");
|
||||
let hashedKey = passwordHash.generate(clearKey);
|
||||
key["key"] = hashedKey;
|
||||
let bean = await APIKey.save(key, socket.userID);
|
||||
@ -25,9 +25,9 @@ module.exports.apiKeySocketHandler = (socket) => {
|
||||
log.debug("apikeys", "Added API Key");
|
||||
log.debug("apikeys", key);
|
||||
|
||||
// Append key ID to start of key seperated by -, used to get
|
||||
// Append key ID and prefix to start of key seperated by _, used to get
|
||||
// correct hash when validating key.
|
||||
let formattedKey = bean.id + "-" + clearKey;
|
||||
let formattedKey = "uk" + bean.id + "_" + clearKey;
|
||||
await sendAPIKeyList(socket);
|
||||
|
||||
// Enable API auth if the user creates a key, otherwise only basic
|
||||
|
Reference in New Issue
Block a user