From dc58a7878faf1ee567e0f1239d8c8869502fd03d Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 5 Dec 2025 13:49:02 +0100 Subject: Federation work --- .../Controllers/TestController.cs | 47 +++++++++++----------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'Utilities/LibMatrix.FederationTest/Controllers/TestController.cs') diff --git a/Utilities/LibMatrix.FederationTest/Controllers/TestController.cs b/Utilities/LibMatrix.FederationTest/Controllers/TestController.cs index 9c0981d..900c8a0 100644 --- a/Utilities/LibMatrix.FederationTest/Controllers/TestController.cs +++ b/Utilities/LibMatrix.FederationTest/Controllers/TestController.cs @@ -1,10 +1,8 @@ using System.Text.Json.Nodes; -using LibMatrix.Abstractions; using LibMatrix.Extensions; using LibMatrix.Federation; using LibMatrix.Federation.Extensions; using LibMatrix.FederationTest.Services; -using LibMatrix.Homeservers; using Microsoft.AspNetCore.Mvc; namespace LibMatrix.FederationTest.Controllers; @@ -21,32 +19,33 @@ public class TestController(FederationTestConfiguration config, FederationKeySto BaseAddress = new Uri("https://matrix.rory.gay") }; - var keyId = new VersionedKeyId() { - Algorithm = "ed25519", - KeyId = "0" - }; + var currentKey = keyStore.GetCurrentSigningKey().CurrentSigningKey; var signatureData = new XMatrixAuthorizationScheme.XMatrixRequestSignature() { - Method = "GET", - Uri = "/_matrix/federation/v1/user/devices/@emma:rory.gay", - OriginServerName = config.ServerName, - DestinationServerName = "rory.gay" - } - .Sign(config.ServerName, keyId, keyStore.GetCurrentSigningKey().privateKey); - - var signature = signatureData.Signatures[config.ServerName][keyId]; - var headerValue = new XMatrixAuthorizationScheme.XMatrixAuthorizationHeader() { - Origin = config.ServerName, - Destination = "rory.gay", - Key = keyId, - Signature = signature - }.ToHeaderValue(); - - var req = new HttpRequestMessage(HttpMethod.Get, "/_matrix/federation/v1/user/devices/@emma:rory.gay"); - req.Headers.Add("Authorization", headerValue); - + OriginServerName = config.ServerName, + Method = "GET", + DestinationServerName = "rory.gay", + Uri = "/_matrix/federation/v1/user/devices/@emma:rory.gay", + }; + // .Sign(currentKey); + // + // var signature = signatureData.Signatures[config.ServerName][currentKey.KeyId]; + // var headerValue = new XMatrixAuthorizationScheme.XMatrixAuthorizationHeader() { + // Origin = config.ServerName, + // Key = currentKey.KeyId, + // Destination = "rory.gay", + // Signature = signature + // }.ToHeaderValue(); + + // var req = new HttpRequestMessage(HttpMethod.Get, "/_matrix/federation/v1/user/devices/@emma:rory.gay"); + // req.Headers.Add("Authorization", headerValue); + + var req = signatureData.ToSignedHttpRequestMessage(currentKey); var response = await hc.SendAsync(req); var content = await response.Content.ReadFromJsonAsync(); return content!; } + + // [HttpGet("/testMakeJoin")] + // public async Task GetTestMakeJoin() { } } \ No newline at end of file -- cgit 1.5.1