mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-21 06:31:51 +00:00
Allow metadata retrieval with Codeberg Pages v2 authorization method.
This commit is contained in:
14
src/auth.go
14
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...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user