mirror of
https://github.com/restic/rest-server.git
synced 2025-12-06 17:15:45 -08:00
htpasswd: allow underscores in usernames
This commit is contained in:
@@ -100,7 +100,7 @@ func (h *HtpasswdFile) throttleTimer() {
|
||||
}
|
||||
}
|
||||
|
||||
var validUsernameRegexp = regexp.MustCompile(`^[\p{L}\d@.-]+$`)
|
||||
var validUsernameRegexp = regexp.MustCompile(`^[\p{L}\d@._-]+$`)
|
||||
|
||||
// Reload reloads the htpasswd file. If the reload fails, the Users map is not changed and the error is returned.
|
||||
func (h *HtpasswdFile) Reload() error {
|
||||
@@ -122,7 +122,7 @@ func (h *HtpasswdFile) Reload() error {
|
||||
users := make(map[string]string)
|
||||
for _, record := range records {
|
||||
if !validUsernameRegexp.MatchString(record[0]) {
|
||||
log.Printf("Ignoring invalid username %q in htpasswd, consists of characters other than letters", record[0])
|
||||
log.Printf("Ignoring invalid username %q in htpasswd, consists of characters other than letters, numbers, '_', '-', '.' and '@'", record[0])
|
||||
continue
|
||||
}
|
||||
users[record[0]] = record[1]
|
||||
|
||||
Reference in New Issue
Block a user