Allow metadata retrieval with Codeberg Pages v2 authorization method.

This commit is contained in:
Catherine
2025-10-09 13:43:00 +00:00
parent e0b659f668
commit d887ae1602

View File

@@ -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...)
}