From a572436c8a2e19a68d347a57528c4646d2070916 Mon Sep 17 00:00:00 2001 From: JackTerok Date: Fri, 19 Feb 2021 16:20:03 +0100 Subject: [PATCH] properly mask the ServerAPIToken in the web interface --- Core/Main/PTMagicConfiguration.cs | 19 +++++++++++++++++++ Monitor/Pages/SettingsGeneral.cshtml | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Core/Main/PTMagicConfiguration.cs b/Core/Main/PTMagicConfiguration.cs index 7d29d14..64eda87 100644 --- a/Core/Main/PTMagicConfiguration.cs +++ b/Core/Main/PTMagicConfiguration.cs @@ -83,6 +83,25 @@ namespace Core.Main return result; } + public string GetProfitTrailerServerAPITokenMasked() + { + string result = ""; + + if (!this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Equals("")) + { + result = this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Substring(0, 4); + + for (int i = 1; i < this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length - 8; i++) + { + result += "*"; + } + + result += this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Substring(this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length - 4); + } + + return result; + } + public GeneralSettings GeneralSettings { get diff --git a/Monitor/Pages/SettingsGeneral.cshtml b/Monitor/Pages/SettingsGeneral.cshtml index 64c3783..c128641 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml +++ b/Monitor/Pages/SettingsGeneral.cshtml @@ -92,7 +92,7 @@
- + @Model.PTMagicConfiguration.GetProfitTrailerServerAPITokenMasked()