Lots of progress on public AP interface
Some checks failed
/ docker (push) Failing after 2m57s

- Read handler for create activities (notes only so far)
- Read handler for note objects
- Structure laid out for other objects, activities and collections
- DB structure for activities created
- Update access logging

TODO: Create collections type in DB to describe a collection group
This commit is contained in:
Melody Becker 2025-05-04 22:08:06 +02:00
parent cfa0566c6d
commit 12c9e17c4b
Signed by: mstar
SSH key fingerprint: SHA256:vkXfS9FG2pVNVfvDrzd1VW9n8VJzqqdKQGljxxX8uK8
24 changed files with 1327 additions and 206 deletions

View file

@ -64,13 +64,13 @@ func BuildAuthorizedFetchCheck(forNonGet bool, forGet bool) webutils.HandlerBuil
if !config.GlobalConfig.Experimental.AuthFetchForServerActor &&
strings.Contains(path, storage.ServerActorId) {
log.Info().Msg("Server actor requested, no auth")
log.Debug().Msg("Server actor requested, no auth")
h.ServeHTTP(w, r)
return
}
// Not an always open path, check methods
if r.Method == "GET" && !forGet {
log.Info().Msg("Get request to AP resources don't need signature")
log.Debug().Msg("Get request to AP resources don't need signature")
h.ServeHTTP(w, r)
return
} else if !forGet && !forNonGet {
@ -78,7 +78,7 @@ func BuildAuthorizedFetchCheck(forNonGet bool, forGet bool) webutils.HandlerBuil
h.ServeHTTP(w, r)
return
}
log.Info().Msg("Need signature for AP request")
log.Debug().Msg("Need signature for AP request")
rawDate := r.Header.Get("Date")
date, err := http.ParseTime(rawDate)
if err != nil {

View file

@ -0,0 +1,28 @@
package webmiddleware
import (
"bytes"
"io"
"net/http"
"time"
webutils "git.mstar.dev/mstar/goutils/http"
"github.com/rs/zerolog/hlog"
)
func TraceRequestInfoMiddleware(h http.Handler) http.Handler {
return webutils.ChainMiddlewares(
h,
hlog.AccessHandler(func(r *http.Request, status, size int, duration time.Duration) {
body, _ := io.ReadAll(r.Body)
r.Body = io.NopCloser(bytes.NewReader(body))
hlog.FromRequest(r).Trace().Any("headers", r.Header).
Bytes("body", body).
Str("method", r.Method).
Stringer("url", r.URL).
Int("status", status).
Int("size", size).
Dur("duration", duration)
}),
)
}