[backend/federation] Verify actor publicKey host

This commit is contained in:
Laura Hausmann 2024-02-16 03:43:35 +01:00
parent 9496d81abe
commit 2da0f95026
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -128,7 +128,9 @@ public class ASActor : ASObject {
!Regex.IsMatch(Username, @"^\w([\w-.]*\w)?$"))
throw new Exception("Actor username is invalid");
//TODO: validate publicKey id host
var publicKeyId = PublicKey?.Id ?? throw new Exception("Invalid actor: missing PublicKey?.Id");
if (new Uri(publicKeyId).Host != new Uri(uri).Host)
throw new Exception("Invalid actor: public key id / actor id host mismatch");
DisplayName = DisplayName switch {
{ Length: > 0 } => DisplayName.Truncate(DisplayNameLength),