Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow underscores in usernames #183

Merged
merged 1 commit into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/issue-182
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Allow usernames containing underscore

The security fix in rest-server 0.11.0 (#131) disallowed usernames containing
and underscore "_". We have changed the list of allowed characters to now include
unicode characters, numbers, "_", "-", "." and "@".

https://github.com/restic/restic/issues/183
https://github.com/restic/restic/pull/184
4 changes: 2 additions & 2 deletions htpasswd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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]
Expand Down