Skip to content

Commit 36c7652

Browse files
committed
Config: per-user overrides for some settings
Allow per-user overrides for AppendOnly and PrivateRepos.
1 parent 383514a commit 36c7652

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

handlers.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,20 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
8383
return
8484
}
8585

86+
// Allow per-user overrides
87+
appendOnly := s.AppendOnly
88+
privateRepos := s.PrivateRepos
89+
if uc, ok := s.Config.Users[username]; ok {
90+
if uc.AppendOnly != nil {
91+
appendOnly = *uc.AppendOnly
92+
}
93+
if uc.PrivateRepos != nil {
94+
privateRepos = *uc.PrivateRepos
95+
}
96+
}
97+
8698
// Check if the current user is allowed to access this path
87-
if !s.NoAuth && s.PrivateRepos {
99+
if !s.NoAuth && privateRepos {
88100
if len(folderPath) == 0 || folderPath[0] != username {
89101
httpDefaultError(w, http.StatusUnauthorized)
90102
return
@@ -102,7 +114,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
102114

103115
// Pass the request to the repo.Handler
104116
opt := repo.Options{
105-
AppendOnly: s.AppendOnly,
117+
AppendOnly: appendOnly,
106118
Debug: s.Debug,
107119
QuotaManager: s.quotaManager, // may be nil
108120
PanicOnError: s.PanicOnError,

0 commit comments

Comments
 (0)