Skip to content

Commit

Permalink
New: Set Reporting Username and PW as Variable
Browse files Browse the repository at this point in the history
  • Loading branch information
rzander committed Feb 23, 2018
1 parent 5025b99 commit 6e9ef97
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
10 changes: 8 additions & 2 deletions source/jaindb/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ public string GetPS()
if (System.IO.File.Exists("/app/wwwroot/inventory.ps1"))
{
string sFile = System.IO.File.ReadAllText("/app/wwwroot/inventory.ps1");
sResult = sFile.Replace("%LocalURL%", Environment.GetEnvironmentVariable("localURL")).Replace("%WebPort%", Environment.GetEnvironmentVariable("WebPort"));
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WebPort")))
sResult = sFile.Replace("%LocalURL%", Environment.GetEnvironmentVariable("localURL")).Replace(":%WebPort%", "");
else
sResult = sFile.Replace("%LocalURL%", Environment.GetEnvironmentVariable("localURL")).Replace("%WebPort%", Environment.GetEnvironmentVariable("WebPort"));

//Cache result in Memory
if (!string.IsNullOrEmpty(sResult))
Expand All @@ -115,7 +118,10 @@ public string GetPS()
if (System.IO.File.Exists(sCurrDir + "/wwwroot/inventory.ps1"))
{
string sFile = System.IO.File.ReadAllText(sCurrDir + "/wwwroot/inventory.ps1");
sResult = sFile.Replace("%LocalURL%", Environment.GetEnvironmentVariable("localURL")).Replace("%WebPort%", Environment.GetEnvironmentVariable("WebPort"));
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WebPort")))
sResult = sFile.Replace("%LocalURL%", Environment.GetEnvironmentVariable("localURL")).Replace(":%WebPort%", "");
else
sResult = sFile.Replace("%LocalURL%", Environment.GetEnvironmentVariable("localURL")).Replace("%WebPort%", Environment.GetEnvironmentVariable("WebPort"));

//Cache result in Memory
if (!string.IsNullOrEmpty(sResult))
Expand Down
2 changes: 2 additions & 0 deletions source/jaindb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ ENV UseRedis 1
ENV UseCosmosDB 0
ENV UseFileSystem 0
ENV StartDelay 3000
ENV ReportUser = "DEMO"
ENV ReportPW = "password"
5 changes: 4 additions & 1 deletion source/jaindb/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"localURL": "https://jaindb.azurewebsites.net",
"ReportPW": "password",
"ASPNETCORE_ENVIRONMENT": "Development",
"ReportUser": "DEMO"
},
"applicationUrl": "http://localhost:59345/"
}
Expand Down
10 changes: 7 additions & 3 deletions source/jaindb/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,18 @@ private void OnStartup()
catch { }

if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WebPort")))
Environment.SetEnvironmentVariable("WebPort", "5000");
Environment.SetEnvironmentVariable("WebPort", "");
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("localURL")))
Environment.SetEnvironmentVariable("localURL", "http://" + sIP);

Console.WriteLine(" ");
Console.WriteLine("-------------------------------------------------------------------");
Console.WriteLine("PowerShell Inventory:");
Console.WriteLine(Environment.ExpandEnvironmentVariables("Invoke-RestMethod -Uri '%localURL%:%WebPort%/getps' | iex"));
if(string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WebPort")))
Console.WriteLine(Environment.ExpandEnvironmentVariables("Invoke-RestMethod -Uri '%localURL%/getps' | iex"));
else
Console.WriteLine(Environment.ExpandEnvironmentVariables("Invoke-RestMethod -Uri '%localURL%:%WebPort%/getps' | iex"));

Console.WriteLine("-------------------------------------------------------------------");
Console.WriteLine(" ");

Expand Down Expand Up @@ -250,7 +254,7 @@ private void OnStartup()

private Task OnSignIn(BasicSignInContext context)
{
if ((context.Password == "password") && (context.UserName =="DEMO"))
if ((context.Password == Environment.GetEnvironmentVariable("ReportPW")) && (context.UserName == Environment.GetEnvironmentVariable("ReportUser")))
{
var claims = new[] { new Claim(ClaimsIdentity.DefaultNameClaimType, context.UserName) };

Expand Down
4 changes: 2 additions & 2 deletions source/jaindb/jaindb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<RepositoryUrl>https://github.com/rzander/jaindb</RepositoryUrl>
<PackageTags>blockchain json</PackageTags>
<Version>0.9.0</Version>
<AssemblyVersion>0.9.0.36</AssemblyVersion>
<FileVersion>0.9.0.36</FileVersion>
<AssemblyVersion>0.9.0.38</AssemblyVersion>
<FileVersion>0.9.0.38</FileVersion>
<StartupObject>jaindb.Program</StartupObject>
<UserSecretsId>fcfd6c0a-e53c-46cb-8a9d-b786c0579861</UserSecretsId>
</PropertyGroup>
Expand Down

0 comments on commit 6e9ef97

Please # to comment.