From 99bc50f2ffe01ebce45a010ca56beb0c2ab05f8c Mon Sep 17 00:00:00 2001 From: Tedy Stoica Date: Tue, 8 Jan 2019 12:15:20 +0200 Subject: [PATCH 1/2] Modified regex --- .../backends/file/FileUsersDatabase.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/lib/authentication/backends/file/FileUsersDatabase.ts b/server/src/lib/authentication/backends/file/FileUsersDatabase.ts index d34dde21..8db919d1 100644 --- a/server/src/lib/authentication/backends/file/FileUsersDatabase.ts +++ b/server/src/lib/authentication/backends/file/FileUsersDatabase.ts @@ -36,13 +36,13 @@ export class FileUsersDatabase implements IUsersDatabase { this.queue.next(); }); }) - .then((content) => { - const database = Yaml.parse(content); - if (!database) { - return Bluebird.reject(new Error("Unable to parse YAML file.")); - } - return Bluebird.resolve(database); - }); + .then((content) => { + const database = Yaml.parse(content); + if (!database) { + return Bluebird.reject(new Error("Unable to parse YAML file.")); + } + return Bluebird.resolve(database); + }); } /** @@ -68,7 +68,7 @@ export class FileUsersDatabase implements IUsersDatabase { password: string) : Bluebird { const storedHash: string = database.users[username].password; - const matches = storedHash.match(/rounds=([0-9]+)\$([a-zA-z0-9]+)\$/); + const matches = storedHash.match(/rounds=([0-9]+)\$([a-zA-z0-9.]+)\$/); if (!(matches && matches.length == 3)) { return Bluebird.reject(new Error("Unable to detect the hash salt and rounds. " + "Make sure the password is hashed with SSHA512.")); @@ -153,7 +153,7 @@ export class FileUsersDatabase implements IUsersDatabase { return { emails: emails, groups: groups }; }); }); - }); + }); } getEmails(username: string): Bluebird { From 0bbf4dc2991f3820f42895e823adb283050c7fc4 Mon Sep 17 00:00:00 2001 From: Tedy Stoica Date: Tue, 8 Jan 2019 12:52:17 +0200 Subject: [PATCH 2/2] Added "/" to regex --- .../src/lib/authentication/backends/file/FileUsersDatabase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/lib/authentication/backends/file/FileUsersDatabase.ts b/server/src/lib/authentication/backends/file/FileUsersDatabase.ts index 8db919d1..cf822540 100644 --- a/server/src/lib/authentication/backends/file/FileUsersDatabase.ts +++ b/server/src/lib/authentication/backends/file/FileUsersDatabase.ts @@ -68,7 +68,7 @@ export class FileUsersDatabase implements IUsersDatabase { password: string) : Bluebird { const storedHash: string = database.users[username].password; - const matches = storedHash.match(/rounds=([0-9]+)\$([a-zA-z0-9.]+)\$/); + const matches = storedHash.match(/rounds=([0-9]+)\$([a-zA-z0-9./]+)\$/); if (!(matches && matches.length == 3)) { return Bluebird.reject(new Error("Unable to detect the hash salt and rounds. " + "Make sure the password is hashed with SSHA512."));