From b7d1fb09414d1fa4127391bd95c02f9d9ca89c9f Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 20 Jun 2025 21:09:39 +0200 Subject: X-Matrix fixes --- LibMatrix.Federation/XMatrixAuthorizationScheme.cs | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'LibMatrix.Federation/XMatrixAuthorizationScheme.cs') diff --git a/LibMatrix.Federation/XMatrixAuthorizationScheme.cs b/LibMatrix.Federation/XMatrixAuthorizationScheme.cs index 5025434..fc402b7 100644 --- a/LibMatrix.Federation/XMatrixAuthorizationScheme.cs +++ b/LibMatrix.Federation/XMatrixAuthorizationScheme.cs @@ -1,5 +1,6 @@ using System.Net; using System.Net.Http.Headers; +using System.Text.Json.Nodes; using System.Text.Json.Serialization; using ArcaneLibs.Extensions; using Microsoft.Extensions.Primitives; @@ -28,7 +29,7 @@ public class XMatrixAuthorizationScheme { Error = $"Expected authentication scheme of {Scheme}, got {header.Scheme}", ErrorCode = MatrixException.ErrorCodes.M_UNAUTHORIZED }; - + if (string.IsNullOrWhiteSpace(header.Parameter)) throw new LibMatrixException() { Error = $"Expected authentication header to have a value.", @@ -36,8 +37,7 @@ public class XMatrixAuthorizationScheme { }; var headerValues = new StringValues(header.Parameter); - foreach (var value in headerValues) - { + foreach (var value in headerValues) { Console.WriteLine(headerValues.ToJson()); } @@ -51,4 +51,21 @@ public class XMatrixAuthorizationScheme { public string ToHeaderValue() => $"{Scheme} origin=\"{Origin}\", destination=\"{Destination}\", key=\"{Key}\", sig=\"{Signature}\""; } + + public class XMatrixRequestSignature { + [JsonPropertyName("method")] + public required string Method { get; set; } + + [JsonPropertyName("uri")] + public required string Uri { get; set; } + + [JsonPropertyName("origin")] + public required string OriginServerName { get; set; } + + [JsonPropertyName("destination")] + public required string DestinationServerName { get; set; } + + [JsonPropertyName("content"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public JsonObject? Content { get; set; } + } } \ No newline at end of file -- cgit 1.5.1