- Add proxy endpoint for proxying a message to a target's inbox - Change duck embed to fs based to fix mk not understanding it
This commit is contained in:
parent
d70786439e
commit
415cd89792
8 changed files with 104 additions and 17 deletions
|
@ -5,10 +5,12 @@ import (
|
|||
"crypto/sha256"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"io"
|
||||
"net/http"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yaronf/httpsign"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/config"
|
||||
|
@ -77,11 +79,16 @@ func RequestSignedCavage(
|
|||
body []byte,
|
||||
actor *models.User,
|
||||
) (*http.Response, error) {
|
||||
req, err := NewRequest(method, target, nil)
|
||||
var bodyReader io.Reader
|
||||
if body != nil {
|
||||
bodyReader = bytes.NewReader(body)
|
||||
}
|
||||
req, err := NewRequest(method, target, bodyReader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Add("Accept", "application/activity+json")
|
||||
req.Header.Add("Content-Type", "application/activity+json")
|
||||
|
||||
var keyBytes []byte
|
||||
if config.GlobalConfig.Experimental.UseEd25519Keys {
|
||||
|
@ -101,6 +108,7 @@ func RequestSignedCavage(
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debug().Bytes("body", body).Any("headers", req.Header).Msg("Sending signed request")
|
||||
return RequestClient.Do(req)
|
||||
}
|
||||
|
||||
|
@ -119,7 +127,7 @@ func applyBodyHash(headers http.Header, body []byte) error {
|
|||
return nil
|
||||
}
|
||||
hash := sha256.Sum256(body)
|
||||
based := base64.StdEncoding.EncodeToString(hash[:])
|
||||
headers.Set("Digest", "SHA-256="+based)
|
||||
header := "SHA-256=" + base64.StdEncoding.EncodeToString(hash[:])
|
||||
headers.Set("Digest", header)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue