Expand description
Checking a signed request that arrives in an inbox.
In three steps, kept apart so that each can be inspected and tested alone:
parsereads the signature, draft-cavage or RFC 9421, into plain data: which key signed, when, and what it covers.checkapplies the policy a signature has to meet before its key is even fetched: it covers the request target, the host, when it was made and, for a request with a body, the body’s digest; the digest is there and matches the body; it was made recently and has not expired; and it was made for this server.verifychecks the signature against a key the caller found.
What lies between the second and third steps — fetching the key, and
checking that the actor who signed is the actor the activity is from — is
the caller’s, since it needs the network and the application’s cache.
key_owner and published_key_pem are the pure halves of that.
Without the second step a signature over date alone would authorise any
body, and a request captured on its way to another server, or an hour
ago, could be replayed here. signature::verify_request checks a digest
only when one happens to be sent, and never the time or the host.
Structs§
- Policy
- What a signature has to meet.
- Request
- A request as it arrived.
- Signature
- A signature, read but not yet checked.
Enums§
- Key
- The key a signature is checked against.
- Published
Key - A key an actor publishes, as a signature is checked against it.
- Rejection
- Why a request is refused.
- Scheme
- Which signature scheme a request is signed with.
Functions§
- check
- Apply
policytosignatureonrequest,nowbeing seconds since the Unix epoch. - key_
owner - The actor a key ID most likely belongs to: the key ID without its
fragment, or without GoToSocial’s
/main-keypath, which is where the key is fetched from and whose owner is then checked. - parse
- Read the signature on
request. - published_
key key_idifactorpublishes it as its own key: aspublished_key_pemreads apublicKey, or an Ed25519assertionMethodMultikey (FEP-521a) whoseidiskey_idand whosecontrolleris the actor.- published_
key_ pem - The PEM of
key_idifactorpublishes it as its own key: apublicKeywhoseidiskey_idand whoseowner, if it names one, is the actor. - verify
- Check
signatureonrequestagainstkey.