From 24dcbb3d518e23bb5a2d6f221971624f5e2f0191 Mon Sep 17 00:00:00 2001 From: Alain St-Denis Date: Wed, 5 Apr 2023 22:39:19 -0400 Subject: [PATCH] Fix logic error. --- federation/protocols/activitypub/signing.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/federation/protocols/activitypub/signing.py b/federation/protocols/activitypub/signing.py index 5f164f6..599705e 100644 --- a/federation/protocols/activitypub/signing.py +++ b/federation/protocols/activitypub/signing.py @@ -53,12 +53,13 @@ def verify_request_signature(request: RequestType, pubkey: str=""): if not signer: signer = retrieve_and_parse_document(sig.get('keyId')) key = getattr(signer, 'public_key', None) - if not key and pubkey: - # fallback to the author's key the client app may have provided - logger.warning("Failed to retrieve keyId for %s, trying the actor's key", sig.get('keyId')) - key = pubkey - else: - raise ValueError(f"No public key for {sig.get('keyId')}") + if not key: + if pubkey: + # fallback to the author's key the client app may have provided + logger.warning("Failed to retrieve keyId for %s, trying the actor's key", sig.get('keyId')) + key = pubkey + else: + raise ValueError(f"No public key for {sig.get('keyId')}") key = encode_if_text(key) date_header = request.headers.get("Date")