fix damage event not including log line

complete initiall implementation for "2FA"
issue #52
issue #66
This commit is contained in:
RaidMax
2019-02-16 15:04:40 -06:00
parent 2bbf2988da
commit 40f1697c97
17 changed files with 115 additions and 98 deletions

View File

@ -21,9 +21,11 @@ namespace WebfrontCore.Controllers
try
{
var client = Manager.GetPrivilegedClients()[clientId];
string[] hashedPassword = await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(password, client.PasswordSalt));
if (hashedPassword[0] == client.Password)
// string[] hashedPassword = await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(password, client.PasswordSalt));
//if (hashedPassword[0] == client.Password)
if (Manager.TokenAuthenticator.AuthorizeToken(client.NetworkId, password))
{
var claims = new[]
{
@ -61,12 +63,5 @@ namespace WebfrontCore.Controllers
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return RedirectToAction("Index", "Home");
}
[HttpGet]
[Authorize]
public async Task<IActionResult> GenerateLoginTokenAsync()
{
return Json(new { token = Manager.TokenAuthenticator.GenerateNextToken(Client.NetworkId) });
}
}
}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore;
using WebfrontCore.ViewModels;
@ -182,5 +183,25 @@ namespace WebfrontCore.Controllers
command = $"!setlevel @{targetId} {level}"
}));
}
public async Task<IActionResult> GenerateLoginTokenForm()
{
var info = new ActionInfo()
{
ActionButtonLabel = "Generate",
Name = "GenerateLoginToken",
Action = "GenerateLoginTokenAsync",
Inputs = new List<InputInfo>()
};
return View("_ActionForm", info);
}
[Authorize]
public string GenerateLoginTokenAsync()
{
var state = Manager.TokenAuthenticator.GenerateNextToken(Client.NetworkId);
return string.Format(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_GENERATETOKEN_SUCCESS"], state.Token, $"{state.RemainingTime} {Utilities.CurrentLocalization.LocalizationIndex["GLOBAL_MINUTES"]}", Client.ClientId);
}
}
}

View File

@ -70,6 +70,7 @@
@class = "dropdown-item bg-dark text-muted text-center text-md-left",
title = "Logout of account"
})
<a class="dropdown-item bg-dark text-muted text-center text-md-left profile-action" href="#" data-action="GenerateLoginToken" aria-hidden="true" title="@loc["WEBFRONT_ACTION_TOKEN"]">@loc["WEBFRONT_ACTION_TOKEN"]</a>
</div>
</li>
<li class="nav-item text-center text-md-left"></li>

View File

@ -1,18 +0,0 @@
<environment include="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator"
crossorigin="anonymous"
integrity="sha384-Fnqn3nxp3506LP/7Y3j/25BlWeA3PXTyT1l78LjECcPaKCV12TsZP7yyMxOe/G/k">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
crossorigin="anonymous"
integrity="sha384-JrXK+k53HACyavUKOsL+NkmSesD2P+73eDMrbTtTk0h4RmOF8hF8apPlkp26JlyH">
</script>
</environment>

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<RuntimeFrameworkVersion>2.2.2</RuntimeFrameworkVersion>
<RazorCompileOnBuild>true</RazorCompileOnBuild>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<RazorCompileOnPublish>true</RazorCompileOnPublish>
<PreserveCompilationContext>true</PreserveCompilationContext>
<TypeScriptToolsVersion>2.6</TypeScriptToolsVersion>
@ -12,7 +12,7 @@
<Authors>RaidMax</Authors>
<Company>Forever None</Company>
<Product>IW4MAdmin</Product>
<Description>IW4MAdmin is a complete server administration tool for IW4x and most Call of Duty® dedicated server</Description>
<Description>IW4MAdmin is a complete server administration tool for IW4x and most Call of Duty® dedicated servers</Description>
<Copyright>2019</Copyright>
<PackageLicenseUrl>https://github.com/RaidMax/IW4M-Admin/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://raidmax.org/IW4MAdmin</PackageProjectUrl>
@ -74,7 +74,5 @@
</ProjectReference>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project>

View File

@ -6416,4 +6416,3 @@ form *, select {
position: fixed;
bottom: 1em;
right: 1em; }

View File

@ -178,7 +178,6 @@
}
.profile-action {
padding-left: 0.25em;
cursor: pointer;
}