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

Add readonly and htpasswd configuration flags #2879

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/kopia/command/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const (
userPasswordFlag = "--user-password"
enablePprof = "--enable-pprof"
metricsListerAddress = "--metrics-listen-addr"
htpasswdFilePath = "--htpasswd-file"

// Repository specific
repositorySubCommand = "repository"
Expand Down Expand Up @@ -121,4 +122,7 @@ const (

// DefaultLogDirectory is the directory where kopia log file is created
DefaultLogDirectory = "/tmp/kopia-log"

// DefaultHtpasswdFilePath is the path to the generated htpasswd file
DefaultHtpasswdFilePath = "/tmp/kopia-htpasswd"
)
11 changes: 11 additions & 0 deletions pkg/kopia/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type ServerStartCommandArgs struct {
TLSKeyFile string
ServerUsername string
ServerPassword string
HtpasswdFilePath string
ReadOnly bool
AutoGenerateCert bool
Background bool
EnablePprof bool
Expand All @@ -39,12 +41,21 @@ func ServerStart(cmdArgs ServerStartCommandArgs) []string {
args = args.AppendLoggableKV(addressFlag, cmdArgs.ServerAddress)
args = args.AppendLoggableKV(tlsCertFilePath, cmdArgs.TLSCertFile)
args = args.AppendLoggableKV(tlsKeyFilePath, cmdArgs.TLSKeyFile)

if cmdArgs.HtpasswdFilePath != "" {
args = args.AppendLoggableKV(htpasswdFilePath, cmdArgs.HtpasswdFilePath)
}

args = args.AppendLoggableKV(serverUsernameFlag, cmdArgs.ServerUsername)
args = args.AppendRedactedKV(serverPasswordFlag, cmdArgs.ServerPassword)

args = args.AppendLoggableKV(serverControlUsernameFlag, cmdArgs.ServerUsername)
args = args.AppendRedactedKV(serverControlPasswordFlag, cmdArgs.ServerPassword)

if cmdArgs.ReadOnly {
args = args.AppendLoggable(readOnlyFlag)
}

if cmdArgs.EnablePprof {
args = args.AppendLoggable(enablePprof)
}
Expand Down
Loading