From d887ae1602a5e9c1343cc4c579253c2f4d4d24d3 Mon Sep 17 00:00:00 2001 From: Catherine Date: Thu, 9 Oct 2025 13:43:00 +0000 Subject: [PATCH] Allow metadata retrieval with Codeberg Pages v2 authorization method. --- src/auth.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/auth.go b/src/auth.go index a177ead..facc1e8 100644 --- a/src/auth.go +++ b/src/auth.go @@ -265,7 +265,7 @@ func authorizeCodebergPagesV2(r *http.Request) (*Authorization, error) { } if len(dnsRecords) > 0 { - log.Printf("auth: %s TXT/CNAME: %v\n", host, dnsRecords) + log.Printf("auth: %s TXT/CNAME: %q\n", host, dnsRecords) } for _, dnsRecord := range dnsRecords { @@ -339,6 +339,18 @@ func AuthorizeMetadataRetrieval(r *http.Request) (*Authorization, error) { } } + if config.Feature("codeberg-pages-compat") { + auth, err = authorizeCodebergPagesV2(r) + if err != nil && IsUnauthorized(err) { + causes = append(causes, err) + } else if err != nil { // bad request + return nil, err + } else { + log.Printf("auth: codeberg %s\n", r.Host) + return auth, nil + } + } + return nil, errors.Join(causes...) }