diff options
Diffstat (limited to 'registry')
-rw-r--r-- | registry/registry.go | 58 |
1 files changed, 3 insertions, 55 deletions
diff --git a/registry/registry.go b/registry/registry.go index 353cfeb..c6c317c 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -211,7 +211,7 @@ func (r *Registry) Inbox(name string, req *http.Request, payload []byte) error { } r.deliverAcceptToInbox(url, actorUrl, actorKeyUrl, follow, handler.handlerCfg) - // subscribeActorToHandler() + // r.subscribeActorToHandler() return nil }, func(c context.Context, note vocab.ActivityStreamsUndo) error { // Unfollow @@ -220,6 +220,7 @@ func (r *Registry) Inbox(name string, req *http.Request, payload []byte) error { inboxProp := person.GetActivityStreamsInbox() url := inboxProp.GetIRI() logger.With("actor", idPropUrl).With("inbox", url).Debugf("undo") + // r.unsubscribeActorToHandler() return nil }) err = resolver.Resolve(ctx, followData) @@ -261,70 +262,17 @@ func (r *Registry) deliverAcceptToInbox(url, actorUrl, actorKeyUrl *url.URL, fol request.Header.Set("Content-Type", "application/activity+json") request.Header.Set("Host", url.Host) - // h := sha256.New() - // h.Write(jsonData) - // digestHeader := base64.StdEncoding.Strict().EncodeToString(h.Sum(nil)) - // request.Header.Add("Digest", "SHA-256="+digestHeader) - // request.Header.Add("Content-Type", "application/activity+json") - - // signedString := fmt.Sprintf("(request-target): post %s\ndate: %s\ndigest: %s\nhost: %s", url.Path, date, digestHeader, url.Host) - - r.log.With( - "type", - "delivery", - ).With( - "payload", - payload, - // ).With( - // "signature string", - // signedString, - ).With( - "host", - request.Header.Get("host"), - ).Debugf("signing request") - - //manual mode - // digestBytes := sha256.Sum256([]byte(signedString)) - // r.mu.Lock() - // signature, err := rsa.SignPKCS1v15(rand.Reader, privKey, crypto.SHA256, digestBytes[:]) - // if err != nil { - // return err - // } - - // // TODO sanity check: decode our own public key from our PEM representation and attempt to verify - // err = rsa.VerifyPKCS1v15(&privKey.PublicKey, crypto.SHA256, digestBytes[:], signature) - // if err != nil { - // return err - // } else { - // r.log.With("type", "delivery").Debugf("verified own signature") - // } - // r.mu.Unlock() - - // b64sig := base64.StdEncoding.Strict().EncodeToString(signature) - // var header = `keyId="` + actorKeyUrl.String() + `",algorithm="hs2019",headers="(request-target) date digest host",signature="` + b64sig + `"` - // request.Header.Add("Signature", header) - - //http sig signing code - broken? r.mu.Lock() prefs := []httpsig.Algorithm{} digestAlgorithm := httpsig.DigestSha256 - // The "Date" and "Digest" headers must already be set on r, as well as r.URL. headersToSign := []string{httpsig.RequestTarget, "host", "date", "digest"} signer, _, err := httpsig.NewSigner(prefs, digestAlgorithm, headersToSign, httpsig.Signature, 0) if err != nil { return err } - // To sign the digest, we need to give the signer a copy of the body... - // ...but it is optional, no digest will be signed if given "nil" - // body := nil - // If r were a http.ResponseWriter, call SignResponse instead. err = signer.SignRequest(privKey, actorKeyUrl.String(), request, jsonData) r.mu.Unlock() - // // HACK - // oldSig := request.Header.Get("signature") - // request.Header.Set("signature", strings.ReplaceAll(oldSig, "hs2019", "rsa-sha256")) - r.log.With( "type", "delivery", @@ -349,7 +297,7 @@ func (r *Registry) deliverAcceptToInbox(url, actorUrl, actorKeyUrl *url.URL, fol } responseBody, err := io.ReadAll(response.Body) defer response.Body.Close() - r.log.With("type", "delivery").With("response", responseBody).With("status", response.Status).Debugf("received") + r.log.With("type", "delivery").With("response", responseBody).With("status", response.Status).Debugf("remote inbox response received") return err } |