Skip to content

Commit

Permalink
Config: per-user overrides for some settings
Browse files Browse the repository at this point in the history
Allow per-user overrides for AppendOnly and PrivateRepos.
  • Loading branch information
wojas committed Aug 9, 2021
1 parent 383514a commit 36c7652
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,20 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

// Allow per-user overrides
appendOnly := s.AppendOnly
privateRepos := s.PrivateRepos
if uc, ok := s.Config.Users[username]; ok {
if uc.AppendOnly != nil {
appendOnly = *uc.AppendOnly
}
if uc.PrivateRepos != nil {
privateRepos = *uc.PrivateRepos
}
}

// Check if the current user is allowed to access this path
if !s.NoAuth && s.PrivateRepos {
if !s.NoAuth && privateRepos {
if len(folderPath) == 0 || folderPath[0] != username {
httpDefaultError(w, http.StatusUnauthorized)
return
Expand All @@ -102,7 +114,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {

// Pass the request to the repo.Handler
opt := repo.Options{
AppendOnly: s.AppendOnly,
AppendOnly: appendOnly,
Debug: s.Debug,
QuotaManager: s.quotaManager, // may be nil
PanicOnError: s.PanicOnError,
Expand Down

0 comments on commit 36c7652

Please sign in to comment.