diff --git a/extra/admin-api/Interop/Spacebar.Interop.Authentication/SpacebarAuthenticationService.cs b/extra/admin-api/Interop/Spacebar.Interop.Authentication/SpacebarAuthenticationService.cs
index 9c00df53c..0e24661c4 100644
--- a/extra/admin-api/Interop/Spacebar.Interop.Authentication/SpacebarAuthenticationService.cs
+++ b/extra/admin-api/Interop/Spacebar.Interop.Authentication/SpacebarAuthenticationService.cs
@@ -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");
}
diff --git a/extra/admin-api/Models/Spacebar.Models.AdminApi/Rights.cs b/extra/admin-api/Models/Spacebar.Models.AdminApi/Rights.cs
index 2928be1e4..8072f1722 100644
--- a/extra/admin-api/Models/Spacebar.Models.AdminApi/Rights.cs
+++ b/extra/admin-api/Models/Spacebar.Models.AdminApi/Rights.cs
@@ -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,
diff --git a/extra/admin-api/Models/Spacebar.Models.Gateway/GuildMEmberEvents.cs b/extra/admin-api/Models/Spacebar.Models.Gateway/GuildMemberEvents.cs
index 210869335..210869335 100644
--- a/extra/admin-api/Models/Spacebar.Models.Gateway/GuildMEmberEvents.cs
+++ b/extra/admin-api/Models/Spacebar.Models.Gateway/GuildMemberEvents.cs
diff --git a/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Pages/Home.razor b/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Pages/Home.razor
index 275ca1463..2b3eb918c 100644
--- a/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Pages/Home.razor
+++ b/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Pages/Home.razor
@@ -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; }
diff --git a/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Program.cs b/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Program.cs
index ba12a172c..2a1040d70 100644
--- a/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Program.cs
+++ b/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Program.cs
@@ -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();
\ No newline at end of file
diff --git a/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Spacebar.AdminApi.TestClient.csproj b/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Spacebar.AdminApi.TestClient.csproj
index 7b588facc..63d8f618b 100644
--- a/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Spacebar.AdminApi.TestClient.csproj
+++ b/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/Spacebar.AdminApi.TestClient.csproj
@@ -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>
diff --git a/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/scripts/deploy.sh b/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/scripts/deploy.sh
new file mode 100755
index 000000000..d7563b2dd
--- /dev/null
+++ b/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/scripts/deploy.sh
@@ -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}
|