about summary refs log tree commit diff
path: root/LibMatrix.Federation/XMatrixAuthorizationScheme.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix.Federation/XMatrixAuthorizationScheme.cs')
-rw-r--r--LibMatrix.Federation/XMatrixAuthorizationScheme.cs23
1 files changed, 20 insertions, 3 deletions
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