rc: Allow user to disable authentication for web gui

This commit is contained in:
negative0 2022-01-23 18:42:42 +05:30 committed by Nick Craig-Wood
parent 2523dd6220
commit e0cbe413e1

View file

@ -95,20 +95,20 @@ func newServer(ctx context.Context, opt *rc.Options, mux *http.ServeMux) *Server
fs.Errorf(nil, "Error while fetching the latest release of Web GUI: %v", err) fs.Errorf(nil, "Error while fetching the latest release of Web GUI: %v", err)
} }
if opt.NoAuth { if opt.NoAuth {
opt.NoAuth = false fs.Logf(nil, "It is recommended to use web gui with auth.")
fs.Infof(nil, "Cannot run Web GUI without authentication, using default auth") } else {
} if opt.HTTPOptions.BasicUser == "" {
if opt.HTTPOptions.BasicUser == "" { opt.HTTPOptions.BasicUser = "gui"
opt.HTTPOptions.BasicUser = "gui" fs.Infof(nil, "No username specified. Using default username: %s \n", rcflags.Opt.HTTPOptions.BasicUser)
fs.Infof(nil, "No username specified. Using default username: %s \n", rcflags.Opt.HTTPOptions.BasicUser) }
} if opt.HTTPOptions.BasicPass == "" {
if opt.HTTPOptions.BasicPass == "" { randomPass, err := random.Password(128)
randomPass, err := random.Password(128) if err != nil {
if err != nil { log.Fatalf("Failed to make password: %v", err)
log.Fatalf("Failed to make password: %v", err) }
opt.HTTPOptions.BasicPass = randomPass
fs.Infof(nil, "No password specified. Using random password: %s \n", randomPass)
} }
opt.HTTPOptions.BasicPass = randomPass
fs.Infof(nil, "No password specified. Using random password: %s \n", randomPass)
} }
opt.Serve = true opt.Serve = true