Преглед изворни кода

feat: change htpasswd to openssl

icaksh пре 9 месеци
родитељ
комит
59362b7477
1 измењених фајлова са 7 додато и 2 уклоњено
  1. 7 2
      backend/internal/access-list.js

+ 7 - 2
backend/internal/access-list.js

@@ -507,8 +507,13 @@ const internalAccessList = {
 								if (typeof item.password !== 'undefined' && item.password.length) {
 									logger.info('Adding: ' + item.username);
 
-									utils.execFile('/usr/bin/htpasswd', ['-b', htpasswd_file, item.username, item.password])
-										.then((/*result*/) => {
+									utils.execFile('openssl', ['passwd', '-apr1', item.password])
+										.then((res) => {
+											try {
+												fs.appendFileSync(htpasswd_file, item.username + ':' + res + '\n', {encoding: 'utf8'});
+											} catch (err) {
+												reject(err);
+											}
 											next();
 										})
 										.catch((err) => {