mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-25 16:42:54 +01:00
Compare commits
1 Commits
0a29b6f21e
...
1ce0c4cfa9
Author | SHA1 | Date | |
---|---|---|---|
1ce0c4cfa9 |
@ -4,7 +4,7 @@ using Phantom.Controller.Database.Entities;
|
||||
|
||||
namespace Phantom.Controller.Services.Users;
|
||||
|
||||
static class UserPasswords {
|
||||
internal static class UserPasswords {
|
||||
private static PasswordHasher<UserEntity> Hasher { get; } = new ();
|
||||
|
||||
private const int MinimumLength = 16;
|
||||
|
@ -17,34 +17,6 @@ public static class Files {
|
||||
await stream.WriteAsync(bytes);
|
||||
}
|
||||
|
||||
public static async Task ReadExactlyBytesAsync(string path, Memory<byte> bytes) {
|
||||
var options = new FileStreamOptions {
|
||||
Mode = FileMode.Open,
|
||||
Access = FileAccess.Read,
|
||||
Options = FileOptions.Asynchronous,
|
||||
Share = FileShare.Read
|
||||
};
|
||||
|
||||
await using var stream = new FileStream(path, options);
|
||||
|
||||
bool wrongLength = false;
|
||||
|
||||
if (stream.Length == bytes.Length) {
|
||||
try {
|
||||
await stream.ReadExactlyAsync(bytes);
|
||||
} catch (EndOfStreamException) {
|
||||
wrongLength = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
wrongLength = true;
|
||||
}
|
||||
|
||||
if (wrongLength) {
|
||||
throw new IOException("Expected file size to be exactly " + bytes.Length + " B, actual size is " + stream.Length + " B.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void RequireMaximumFileSize(string path, long maximumBytes) {
|
||||
var actualBytes = new FileInfo(path).Length;
|
||||
if (actualBytes > maximumBytes) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Phantom.Common.Logging;
|
||||
using Phantom.Controller.Services.Users;
|
||||
using Phantom.Utils.Cryptography;
|
||||
using Phantom.Web.Identity.Interfaces;
|
||||
using ILogger = Serilog.ILogger;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Phantom.Web.Identity.Data;
|
||||
|
||||
namespace Phantom.Web.Identity.Authorization;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Phantom.Web.Identity.Interfaces;
|
||||
using Phantom.Controller.Database.Entities;
|
||||
|
||||
namespace Phantom.Web.Identity.Interfaces;
|
||||
|
||||
public interface ILoginEvents {
|
||||
void UserLoggedIn(UserEntity user);
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Phantom.Web.Identity.Interfaces;
|
||||
using Phantom.Controller.Database.Entities;
|
||||
using Phantom.Controller.Services.Audit;
|
||||
using Phantom.Web.Identity.Interfaces;
|
||||
|
||||
namespace Phantom.Web.Base;
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Phantom.Common.Logging;
|
||||
using Phantom.Web.Identity.Authorization;
|
||||
using Phantom.Web.Identity.Data;
|
||||
using ILogger = Serilog.ILogger;
|
||||
|
||||
namespace Phantom.Web.Base;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Phantom.Controller.Services;
|
||||
using Phantom.Utils.Tasks;
|
||||
using Phantom.Web.Base;
|
||||
using Phantom.Web.Identity;
|
||||
|
@ -1,4 +1,5 @@
|
||||
@inject ServiceConfiguration Configuration
|
||||
@using Phantom.Controller.Services
|
||||
@inject ServiceConfiguration Configuration
|
||||
@inject PermissionManager PermissionManager
|
||||
|
||||
<div class="navbar navbar-dark">
|
||||
|
@ -1,4 +1,5 @@
|
||||
@page "/agents"
|
||||
@using Phantom.Controller.Services.Agents
|
||||
@using Phantom.Utils.Collections
|
||||
@implements IDisposable
|
||||
@inject AgentManager AgentManager
|
||||
|
@ -1,6 +1,10 @@
|
||||
@page "/audit"
|
||||
@attribute [Authorize(Permission.ViewAuditPolicy)]
|
||||
@using Phantom.Controller.Services.Audit
|
||||
@using Phantom.Controller.Services.Instances
|
||||
@using Phantom.Controller.Services.Users
|
||||
@using System.Collections.Immutable
|
||||
@using Phantom.Controller.Database.Enums
|
||||
@implements IDisposable
|
||||
@inject AuditLog AuditLog
|
||||
@inject InstanceManager InstanceManager
|
||||
|
@ -1,6 +1,10 @@
|
||||
@page "/events"
|
||||
@attribute [Authorize(Permission.ViewEventsPolicy)]
|
||||
@using System.Collections.Immutable
|
||||
@using Phantom.Controller.Services.Events
|
||||
@using Phantom.Controller.Services.Instances
|
||||
@using Phantom.Controller.Database.Enums
|
||||
@using Phantom.Controller.Services.Agents
|
||||
@implements IDisposable
|
||||
@inject AgentManager AgentManager
|
||||
@inject EventLog EventLog
|
||||
|
@ -1,6 +1,10 @@
|
||||
@page "/instances/{InstanceGuid:guid}"
|
||||
@attribute [Authorize(Permission.ViewInstancesPolicy)]
|
||||
@inherits PhantomComponent
|
||||
@using Phantom.Common.Data.Instance
|
||||
@using Phantom.Common.Data.Replies
|
||||
@using Phantom.Controller.Services.Audit
|
||||
@using Phantom.Controller.Services.Instances
|
||||
@implements IDisposable
|
||||
@inject InstanceManager InstanceManager
|
||||
@inject AuditLog AuditLog
|
||||
|
@ -1,5 +1,7 @@
|
||||
@page "/instances/{InstanceGuid:guid}/edit"
|
||||
@attribute [Authorize(Permission.CreateInstancesPolicy)]
|
||||
@using Phantom.Common.Data.Instance
|
||||
@using Phantom.Controller.Services.Instances
|
||||
@inherits PhantomComponent
|
||||
@inject InstanceManager InstanceManager
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
@page "/instances"
|
||||
@attribute [Authorize(Permission.ViewInstancesPolicy)]
|
||||
@using System.Collections.Immutable
|
||||
@using Phantom.Controller.Services.Instances
|
||||
@using Phantom.Controller.Services.Agents
|
||||
@implements IDisposable
|
||||
@inject AgentManager AgentManager
|
||||
@inject InstanceManager InstanceManager
|
||||
|
@ -1,8 +1,12 @@
|
||||
@page "/setup"
|
||||
@using Phantom.Controller.Services.Users
|
||||
@using Phantom.Utils.Cryptography
|
||||
@using Phantom.Utils.Tasks
|
||||
@using Phantom.Controller.Database.Entities
|
||||
@using Phantom.Controller.Services
|
||||
@using Phantom.Controller.Services.Audit
|
||||
@using Phantom.Web.Identity.Authentication
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using Phantom.Utils.Cryptography
|
||||
@using System.Security.Cryptography
|
||||
@attribute [AllowAnonymous]
|
||||
@inject ServiceConfiguration ServiceConfiguration
|
||||
|
@ -1,4 +1,6 @@
|
||||
@page "/users"
|
||||
@using Phantom.Controller.Database.Entities
|
||||
@using Phantom.Controller.Services.Users
|
||||
@using System.Collections.Immutable
|
||||
@attribute [Authorize(Permission.ViewUsersPolicy)]
|
||||
@inject UserManager UserManager
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Reflection;
|
||||
using Phantom.Common.Logging;
|
||||
using Phantom.Controller.Services;
|
||||
using Phantom.Utils.Cryptography;
|
||||
using Phantom.Utils.IO;
|
||||
using Phantom.Utils.Runtime;
|
||||
@ -29,7 +30,7 @@ try {
|
||||
PhantomLogger.Root.InformationHeading("Initializing Phantom Panel web...");
|
||||
PhantomLogger.Root.Information("Web version: {Version}", fullVersion);
|
||||
|
||||
var (controllerHost, controllerPort, webKeyToken, webKeyFilePath, webServerHost, webServerPort, webBasePath) = Variables.LoadOrStop();
|
||||
var (webServerHost, webServerPort, webBasePath) = Variables.LoadOrStop();
|
||||
|
||||
string webKeysPath = Path.GetFullPath("./keys");
|
||||
CreateFolderOrStop(webKeysPath, Chmod.URWX);
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace Phantom.Web;
|
||||
namespace Phantom.Controller.Services;
|
||||
|
||||
public sealed record ServiceConfiguration(
|
||||
string Version,
|
||||
|
@ -1,7 +1,9 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using Phantom.Controller.Database.Entities;
|
||||
using Phantom.Web.Base;
|
||||
using Phantom.Web.Components.Forms;
|
||||
using Phantom.Web.Identity.Data;
|
||||
|
||||
namespace Phantom.Web.Shared;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user