[chore] Refactor AP authentication, other small bits of tidying up (#1874)

This commit is contained in:
tobi 2023-06-13 16:47:56 +02:00 committed by GitHub
commit 24fbdf2b0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 1280 additions and 996 deletions

View file

@ -87,7 +87,7 @@ func (t *transport) GET(r *http.Request) (*http.Response, error) {
return nil, errors.New("must be GET request")
}
ctx := r.Context() // extract, set pubkey ID.
ctx = gtscontext.SetPublicKeyID(ctx, t.pubKeyID)
ctx = gtscontext.SetOutgoingPublicKeyID(ctx, t.pubKeyID)
r = r.WithContext(ctx) // replace request ctx.
r.Header.Set("User-Agent", t.controller.userAgent)
return t.controller.client.DoSigned(r, t.signGET())
@ -99,7 +99,7 @@ func (t *transport) POST(r *http.Request, body []byte) (*http.Response, error) {
return nil, errors.New("must be POST request")
}
ctx := r.Context() // extract, set pubkey ID.
ctx = gtscontext.SetPublicKeyID(ctx, t.pubKeyID)
ctx = gtscontext.SetOutgoingPublicKeyID(ctx, t.pubKeyID)
r = r.WithContext(ctx) // replace request ctx.
r.Header.Set("User-Agent", t.controller.userAgent)
return t.controller.client.DoSigned(r, t.signPOST(body))