mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 03:01:48 +00:00
Treat allowed-repository-url-prefixes = [] the same as unspecified.
Previously, this would disallow all git clones except for those via wildcard domains. This is highly unintuitive. It also meant that disabling this function via environment variable was not possible.
This commit is contained in:
@@ -51,7 +51,7 @@ max-symlink-depth = 16
|
||||
update-timeout = "60s"
|
||||
max-heap-size-ratio = 0.5 # * RAM_size
|
||||
forbidden-domains = []
|
||||
# allowed-repository-url-prefixes = <nil>
|
||||
allowed-repository-url-prefixes = []
|
||||
allowed-custom-headers = ["X-Clacks-Overhead"]
|
||||
|
||||
[audit]
|
||||
|
||||
@@ -436,7 +436,7 @@ func AuthorizeUpdateFromRepository(r *http.Request) (*Authorization, error) {
|
||||
}
|
||||
|
||||
func checkAllowedURLPrefix(repoURL string) error {
|
||||
if config.Limits.AllowedRepositoryURLPrefixes != nil {
|
||||
if len(config.Limits.AllowedRepositoryURLPrefixes) > 0 {
|
||||
allowedPrefix := false
|
||||
repoURL = strings.ToLower(repoURL)
|
||||
for _, allowedRepoURLPrefix := range config.Limits.AllowedRepositoryURLPrefixes {
|
||||
@@ -658,7 +658,7 @@ func AuthorizeUpdateFromArchive(r *http.Request) (*Authorization, error) {
|
||||
return auth, nil
|
||||
}
|
||||
|
||||
if config.Limits.AllowedRepositoryURLPrefixes != nil {
|
||||
if len(config.Limits.AllowedRepositoryURLPrefixes) > 0 {
|
||||
causes = append(causes, AuthError{http.StatusUnauthorized, "DNS challenge not allowed"})
|
||||
} else {
|
||||
// DNS challenge gives absolute authority.
|
||||
|
||||
@@ -140,7 +140,7 @@ type LimitsConfig struct {
|
||||
// List of domains unconditionally forbidden for uploads.
|
||||
ForbiddenDomains []string `toml:"forbidden-domains" default:"[]"`
|
||||
// List of allowed repository URL prefixes. Setting this option prohibits uploading archives.
|
||||
AllowedRepositoryURLPrefixes []string `toml:"allowed-repository-url-prefixes"`
|
||||
AllowedRepositoryURLPrefixes []string `toml:"allowed-repository-url-prefixes" default:"[]"`
|
||||
// List of allowed custom headers. Header name must be in the MIME canonical form,
|
||||
// e.g. `Foo-Bar`. Setting this option permits including this custom header in `_headers`,
|
||||
// unless it is fundamentally unsafe.
|
||||
|
||||
Reference in New Issue
Block a user