Skip to content

Commit

Permalink
feat: add file support for secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Jan 28, 2023
1 parent 6668908 commit 6b96519
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Oxide.Ext.GamingApi/GamingApiNats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Threading;
using Asyncapi.Nats.Client;
using NATS.Client.JetStream;
using System.Configuration;
using System.IO;

namespace Oxide.Ext.GamingApi
{
Expand Down Expand Up @@ -162,6 +164,16 @@ private string GetNatsNkeyUser()
private string GetNatsNkeySeed()
{
var envName = $"GAMINGAPI_NATS_NKEY_SEED";
var envFileName = envName + "_FILE";


var fileName = Environment.GetEnvironmentVariable(envFileName);
if (fileName != null)
{
string contents = File.ReadAllText(@fileName);
return contents;
}

var value = Environment.GetEnvironmentVariable(envName);
if (value == null)
{
Expand All @@ -174,7 +186,18 @@ private string GetNatsNkeySeed()

private string GetNatsJwtUser()
{

var envName = $"GAMINGAPI_NATS_JWT_USER";
var envFileName = envName + "_FILE";


var fileName = Environment.GetEnvironmentVariable(envFileName);
if (fileName != null)
{
string contents = File.ReadAllText(@fileName);
return contents;
}

var value = Environment.GetEnvironmentVariable(envName);
if (value == null)
{
Expand Down

0 comments on commit 6b96519

Please sign in to comment.