From 6c774f615e8018f4f2d899888edac239c6f9ce7e Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Thu, 3 Jun 2021 19:08:46 +0100 Subject: [PATCH] Update for 2FA --- .../configuration/sections/system_configuration.dm | 3 +++ code/modules/admin/IsBanned.dm | 2 +- code/modules/client/2fa.dm | 8 ++++---- config/example/config.toml | 4 +++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/code/controllers/configuration/sections/system_configuration.dm b/code/controllers/configuration/sections/system_configuration.dm index 5dad75b349d..a0354bb2b77 100644 --- a/code/controllers/configuration/sections/system_configuration.dm +++ b/code/controllers/configuration/sections/system_configuration.dm @@ -12,6 +12,8 @@ var/shutdown_on_reboot = FALSE /// If above is true, you can run a shell command var/shutdown_shell_command = null + /// 2FA backend server host + var/_2fa_auth_host = null /datum/configuration_section/system_configuration/load_data(list/data) // Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line @@ -21,3 +23,4 @@ CONFIG_LOAD_STR(medal_hub_address, data["medal_hub_address"]) CONFIG_LOAD_STR(medal_hub_password, data["medal_hub_password"]) CONFIG_LOAD_STR(shutdown_shell_command, data["shutdown_shell_command"]) + CONFIG_LOAD_STR(_2fa_auth_host, data["_2fa_auth_host"]) diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 398753755a0..5e5f8c07343 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -45,7 +45,7 @@ // If 2FA is enabled, makes sure they were authed within the last minute - if(check_2fa && config._2fa_auth_host) + if(check_2fa && GLOB.configuration.system._2fa_auth_host) // First see if they exist at all var/datum/db_query/check_query = SSdbcore.NewQuery("SELECT 2fa_status, ip FROM [format_table_name("player")] WHERE ckey=:ckey", list("ckey" = ckey(key))) diff --git a/code/modules/client/2fa.dm b/code/modules/client/2fa.dm index 9de8ef73476..8dc585649f3 100644 --- a/code/modules/client/2fa.dm +++ b/code/modules/client/2fa.dm @@ -1,12 +1,12 @@ // This is in its own file as it has so much stuff to contend with /client/proc/edit_2fa() - if(!config._2fa_auth_host) + if(! GLOB.configuration.system._2fa_auth_host) alert(usr, "This server does not have 2FA enabled.") return // Client does not have 2FA enabled. Set it up. if(prefs._2fa_status == _2FA_DISABLED) // Get us an auth token - var/datum/http_response/qrcr = wrap_http_get("[config._2fa_auth_host]/generateQR?ckey=[ckey]") + var/datum/http_response/qrcr = wrap_http_get("[GLOB.configuration.system._2fa_auth_host]/generateQR?ckey=[ckey]") // If this fails, shits gone bad if(qrcr.errored) alert(usr, "Something has gone VERY wrong ingame. Please inform the server host.\nError details: [qrcr.error]") @@ -33,7 +33,7 @@ B.close() return - var/datum/http_response/vr = wrap_http_get("[config._2fa_auth_host]/validateCode?ckey=[ckey]&code=[entered_code]") + var/datum/http_response/vr = wrap_http_get("[GLOB.configuration.system._2fa_auth_host]/validateCode?ckey=[ckey]&code=[entered_code]") // If this fails, shits gone bad if(vr.errored) alert(usr, "Something has gone VERY wrong ingame. Please inform the server host.\nError details: [vr.error]") @@ -86,7 +86,7 @@ alert(usr, "2FA deactivation aborted!") return - var/datum/http_response/vr = wrap_http_get("[config._2fa_auth_host]/validateCode?ckey=[ckey]&code=[entered_code]") + var/datum/http_response/vr = wrap_http_get("[GLOB.configuration.system._2fa_auth_host]/validateCode?ckey=[ckey]&code=[entered_code]") // If this fails, shits gone bad if(vr.errored) alert(usr, "Something has gone VERY wrong ingame. Please inform the server host.\nError details: [vr.error]") diff --git a/config/example/config.toml b/config/example/config.toml index 18157dbe776..54a79eb25b0 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -140,7 +140,7 @@ ipc_screens = [ # Enable/disable the database on a whole sql_enabled = false # SQL version. If this is a mismatch, round start will be delayed -sql_version = 23 +sql_version = 24 # SQL server address. Can be an IP or DNS name sql_address = "127.0.0.1" # SQL server port @@ -692,6 +692,8 @@ lavaland_ruin_budget = 60 shutdown_on_reboot = false # If true to above, an optional shell command can be ran. Defaults to killing DD on windows #shutdown_shell_command = "taskkill /im dreamdaemon.exe /f" +# URL for the 2FA backend HTTP host. Do not use https:// or a trailing slash. Comment out to disable +#_2fa_auth_host = "http://127.0.0.1:8080" ################################################################