federation: add setting to disable HTTP signature validation

This commit is contained in:
famfo 2025-02-24 01:07:20 +01:00
parent a4f9ffbaf9
commit c8dcd5ee64
No known key found for this signature in database
2 changed files with 6 additions and 0 deletions

View file

@ -19,6 +19,7 @@ var (
DigestAlgorithm string
GetHeaders []string
PostHeaders []string
SignatureEnforced bool
}{
Enabled: false,
ShareUserStatistics: true,
@ -27,6 +28,7 @@ var (
DigestAlgorithm: "SHA-256",
GetHeaders: []string{"(request-target)", "Date", "Host"},
PostHeaders: []string{"(request-target)", "Date", "Host", "Digest"},
SignatureEnforced: true,
}
)

View file

@ -41,6 +41,10 @@ func getPublicKeyFromResponse(b []byte, keyID *url.URL) (p crypto.PublicKey, err
}
func verifyHTTPSignatures(ctx *gitea_context.APIContext) (authenticated bool, err error) {
if !setting.Federation.SignatureEnforced {
return true, nil
}
r := ctx.Req
// 1. Figure out what key we need to verify