From 34d503859b440d163b1c5ba62133ae7a94da013c Mon Sep 17 00:00:00 2001 From: jonaslagoni Date: Sun, 29 Jan 2023 00:54:10 +0100 Subject: [PATCH] fix: not loading jwt secret from file --- Oxide.Ext.GamingApi/GamingApiNats.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Oxide.Ext.GamingApi/GamingApiNats.cs b/Oxide.Ext.GamingApi/GamingApiNats.cs index 0f93211..cb8a536 100644 --- a/Oxide.Ext.GamingApi/GamingApiNats.cs +++ b/Oxide.Ext.GamingApi/GamingApiNats.cs @@ -84,7 +84,7 @@ private GamingApiNats(LoggingInterface logger) { // get a private key seed from your environment. string seed = this.GetNatsJwtSeed(); - this.Logger.Info("NATS: Loading jwt seed : " + seed.Substring(0, 3)); + this.Logger.Info("NATS: Loading jwt seed : " + seed.Substring(seed.Length-4, seed.Length-1)); // Generate a NkeyPair NkeyPair kp = Nkeys.FromSeed(seed); @@ -167,16 +167,6 @@ private string GetNatsNkeyUser() private string GetNatsNkeySeed() { var envName = $"GAMINGAPI_NATS_NKEY_SEED"; - var envFileName = envName + "_FILE"; - - var fileName = Environment.GetEnvironmentVariable(envFileName); - if (fileName != null) - { - this.Logger.Info($"NATS: {envFileName} loading from file"); - string contents = File.ReadAllText(@fileName); - return contents; - } - var value = Environment.GetEnvironmentVariable(envName); this.Logger.Info($"NATS: {envName} loading"); if (value == null) @@ -214,6 +204,15 @@ private string GetNatsJwtUser() private string GetNatsJwtSeed() { var envName = $"GAMINGAPI_NATS_JWT_SEED"; + var envFileName = envName + "_FILE"; + + var fileName = Environment.GetEnvironmentVariable(envFileName); + if (fileName != null) + { + this.Logger.Info($"NATS: {envFileName} loading from file"); + string contents = File.ReadAllText(@fileName); + return contents; + } var value = Environment.GetEnvironmentVariable(envName); if (value == null) {