From e130c290f59e1dff71e3dcf588852e832a6ecf22 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 20 Oct 2021 23:25:32 +0000 Subject: [PATCH] --- .vscode/launch.json | 4 ++-- server/AyaNova/util/AySchema.cs | 2 +- server/AyaNova/util/Hasher.cs | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 8651454c..1fe39e12 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -47,8 +47,8 @@ // "AYANOVA_LOG_LEVEL": "Trace", "AYANOVA_DEFAULT_TRANSLATION": "en", //"AYANOVA_PERMANENTLY_ERASE_DATABASE": "true", - //"AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=raven;Database=AyaNova;CommandTimeout=120;", - "AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=abraxis;Database=AyaNova;CommandTimeout=120;", + "AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=raven;Database=AyaNova;CommandTimeout=120;", + //"AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=abraxis;Database=AyaNova;CommandTimeout=120;", "AYANOVA_USE_URLS": "http://*:7575;", "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 478ebfa7..63e09c92 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -198,7 +198,7 @@ namespace AyaNova.Util cm.CommandText = "CREATE TABLE aschemaversion (schema INTEGER NOT NULL, id TEXT NOT NULL);"; await cm.ExecuteNonQueryAsync(); - cm.CommandText = $"insert into aschemaversion (schema, id) values (0,'{AyaNova.Util.Hasher.GenerateSalt()}');"; + cm.CommandText = $"insert into aschemaversion (schema, id) values (0,'{AyaNova.Util.Hasher.GenerateSalt()}');";//NOTE: this is where the dbid comes from originally await cm.ExecuteNonQueryAsync(); await ct.Database.CloseConnectionAsync(); diff --git a/server/AyaNova/util/Hasher.cs b/server/AyaNova/util/Hasher.cs index e9006a99..d7cc07ea 100644 --- a/server/AyaNova/util/Hasher.cs +++ b/server/AyaNova/util/Hasher.cs @@ -26,8 +26,14 @@ namespace AyaNova.Util } //Generate salt + /* + Used for many things: + DBID, JWT secret key when none provided, User Salt for login / password, + temporary 2fa codes, download tokens, + temporary user pw / login when newly created and haven't been set yet + */ public static string GenerateSalt() - { + { var salt = new byte[32]; var random = RandomNumberGenerator.Create(); random.GetNonZeroBytes(salt);