mirror of
https://github.com/spacebarchat/server.git
synced 2026-11-04 13:29:02 +00:00
Admin api logging fixes, admin api test client publishing tools
This commit is contained in:
1 parent
316e27a08d
commit
c711bf02c9
7 files changed
+58
-4
No files matched your search
+11
-1
@@ -32,11 +32,21 @@ public class SpacebarAuthenticationService(ILogger<SpacebarAuthenticationService
|
||||
public async Task InitializeAsync() {
|
||||
if (_isInitialised) return;
|
||||
|
||||
if (!File.Exists(config.PublicKeyPath)) {
|
||||
logger.LogCritical("SpacebarAuthenticationService: Public key not found at {path}", config.PublicKeyPath);
|
||||
throw new Exception("Authentication failed");
|
||||
}
|
||||
|
||||
var publicKeyFile = await File.ReadAllTextAsync(config.PublicKeyPath);
|
||||
var rawPublicKey = ECDsa.Create(ECCurve.NamedCurves.nistP256);
|
||||
rawPublicKey.ImportFromPem(publicKeyFile);
|
||||
_publicKey = new ECDsaSecurityKey(rawPublicKey);
|
||||
|
||||
if (!File.Exists(config.PublicKeyPath)) {
|
||||
logger.LogCritical("SpacebarAuthenticationService: Private key not found at {path}", config.PrivateKeyPath);
|
||||
throw new Exception("Authentication failed");
|
||||
}
|
||||
|
||||
var privateKeyFile = await File.ReadAllTextAsync(config.PrivateKeyPath);
|
||||
var rawPrivateKey = ECDsa.Create(ECCurve.NamedCurves.nistP256);
|
||||
rawPrivateKey.ImportFromPem(privateKeyFile);
|
||||
@@ -51,7 +61,7 @@ public class SpacebarAuthenticationService(ILogger<SpacebarAuthenticationService
|
||||
var res = await Handler.ValidateTokenAsync(token, TokenValidationParameters);
|
||||
|
||||
if ((!res.IsValid || res.Exception is not null) && !config.DisableAuthentication) {
|
||||
logger.LogInformation("Invalid token");
|
||||
logger.LogWarning("Invalid token: {e}", res.Exception?.ToString() ?? "Unknown failure");
|
||||
throw res.Exception ?? new UnauthorizedAccessException("Token was invalid");
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public static class SpacebarRights {
|
||||
UNUSED_11 = 1ul << 17, //PREVIOUS IDENTITY: CREATE_TEMPLATES
|
||||
UNUSED_12 = 1ul << 18, //PREVIOUS IDENTITY: CREATE_WEBHOOKS
|
||||
JOIN_GUILDS = 1ul << 19,
|
||||
UNUSED_13 = 1ul << 20, //PREVIOUS IDENTITY: PIN_MESSAGES
|
||||
PIN_MESSAGES = 1ul << 20, //PREVIOUS IDENTITY: PIN_MESSAGES
|
||||
SELF_ADD_REACTIONS = 1ul << 21,
|
||||
SELF_DELETE_MESSAGES = 1ul << 22,
|
||||
SELF_EDIT_MESSAGES = 1ul << 23,
|
||||
|
||||
File renamed without changes.
@@ -1,11 +1,25 @@
|
||||
@page "/"
|
||||
@using System.Net.Http.Headers
|
||||
@using Spacebar.AdminApi.TestClient.Services
|
||||
@using Spacebar.Sdk.Core
|
||||
@inject Config Config
|
||||
@inject ILocalStorageService LocalStorage
|
||||
@inject SpacebarClientWellKnownResolverService WellKnownResolver
|
||||
|
||||
<PageTitle>Home</PageTitle>
|
||||
|
||||
<span style="@($"color: {(IsServerNameValid ? "green" : "red")};")">Spacebar instance: </span>
|
||||
<InputText @bind-Value:get="Config.ApiUrl" @bind-Value:set="@(async (v) => {
|
||||
if (v is null) return;
|
||||
var wk = await WellKnownResolver.ResolveClientWellKnown(v);
|
||||
Config.ApiUrl = wk.Api.BaseUrl;
|
||||
Config.CdnUrl = wk.Cdn.BaseUrl;
|
||||
Config.GatewayUrl = wk.Gateway.BaseUrl;
|
||||
if (wk.Admin is not null)
|
||||
Config.AdminUrl = wk.Admin.BaseUrl;
|
||||
await ValidateAndSaveConfig();
|
||||
})"/>
|
||||
<br/>
|
||||
<span style="@($"color: {(IsApiUrlValid ? "green" : "red")};")">Spacebar API URL: </span>
|
||||
<InputText @bind-Value:get="Config.ApiUrl" @bind-Value:set="@(async (v) => {
|
||||
Config.ApiUrl = v!;
|
||||
@@ -41,6 +55,7 @@
|
||||
|
||||
@code {
|
||||
|
||||
private bool IsServerNameValid { get; set; }
|
||||
private bool IsApiUrlValid { get; set; }
|
||||
|
||||
// private bool IsGatewayUrlValid { get; set; }
|
||||
|
||||
@@ -10,6 +10,7 @@ using Microsoft.JSInterop;
|
||||
using Microsoft.JSInterop.WebAssembly;
|
||||
using Spacebar.AdminApi.TestClient;
|
||||
using Spacebar.AdminApi.TestClient.Services;
|
||||
using Spacebar.Sdk.Core;
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
builder.RootComponents.Add<App>("#app");
|
||||
@@ -62,4 +63,6 @@ builder.Services.AddBlazoredLocalStorageAsSingleton(config => {
|
||||
builder.Services.AddSingleton<JsConsoleService>();
|
||||
builder.Services.AddSingleton(sp => (WebAssemblyJSRuntime)sp.GetRequiredService<IJSRuntime>());
|
||||
builder.Services.AddSingleton(sp => (IJSInProcessRuntime)sp.GetRequiredService<IJSRuntime>());
|
||||
builder.Services.AddSingleton<SpacebarClientProviderService>();
|
||||
builder.Services.AddSingleton<SpacebarClientWellKnownResolverService>();
|
||||
await builder.Build().RunAsync();
|
||||
+4
-2
@@ -10,11 +10,12 @@
|
||||
|
||||
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
|
||||
<BlazorEnableCompression>false</BlazorEnableCompression>
|
||||
<CompressionEnabled>false</CompressionEnabled>
|
||||
<BlazorCacheBootResources>false</BlazorCacheBootResources>
|
||||
<!-- <RunAOTCompilation>true</RunAOTCompilation>-->
|
||||
<!-- <RunAOTCompilation>true</RunAOTCompilation> -->
|
||||
<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<!-- <RuntimeFrameworkVersion>10.0.2-servicing.25570.103</RuntimeFrameworkVersion>-->
|
||||
<!-- <RuntimeFrameworkVersion>10.0.2-servicing.25570.103</RuntimeFrameworkVersion> -->
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -44,6 +45,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Models\Spacebar.Models.AdminApi\Spacebar.Models.AdminApi.csproj" />
|
||||
<ProjectReference Include="..\..\Models\Spacebar.Models.Config\Spacebar.Models.Config.csproj" />
|
||||
<ProjectReference Include="..\Spacebar.Sdk\Spacebar.Sdk.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
if [[ -z $(git status -s) ]]
|
||||
then
|
||||
echo "tree is clean"
|
||||
else
|
||||
echo "tree is dirty, please commit changes before running this"
|
||||
# exit
|
||||
fi
|
||||
|
||||
REMOTE_TARGET=`cat .publish_target`
|
||||
if [[ -n "$REMOTE_TARGET" ]]
|
||||
then
|
||||
echo "Publish target is ${REMOTE_TARGET}"
|
||||
else
|
||||
echo "Publish target not set. Please write it in .publish_target (rsync path specifier)"
|
||||
exit
|
||||
fi
|
||||
|
||||
BASE_DIR=`pwd`
|
||||
set -x
|
||||
rm -rf bin/Release
|
||||
dotnet publish -c Release
|
||||
dotnet restore # restore debug deps
|
||||
rsync --delete -raP bin/Release/net10.0/publish/wwwroot/ ${REMOTE_TARGET}
|
||||
Reference in new issue
Block a user