forked from TrueCloudLab/rclone
rc/rcserver: with --rc-files if auth set, pass on to URL opened
If `--rc-user` or `--rc-pass` is set then the URL that is opened with `--rc-files` will have the authorization in the URL in the `http://user:pass@localhost/` style.
This commit is contained in:
parent
2466f4d152
commit
75a88de55c
2 changed files with 14 additions and 1 deletions
|
@ -79,6 +79,10 @@ If this is set then rclone will serve the files in that directory. It
|
||||||
will also open the root in the web browser if specified. This is for
|
will also open the root in the web browser if specified. This is for
|
||||||
implementing browser based GUIs for rclone functions.
|
implementing browser based GUIs for rclone functions.
|
||||||
|
|
||||||
|
If `--rc-user` or `--rc-pass` is set then the URL that is opened will
|
||||||
|
have the authorization in the URL in the `http://user:pass@localhost/`
|
||||||
|
style.
|
||||||
|
|
||||||
Default Off.
|
Default Off.
|
||||||
|
|
||||||
### --rc-no-auth
|
### --rc-no-auth
|
||||||
|
|
|
@ -69,7 +69,16 @@ func (s *Server) Serve() error {
|
||||||
fs.Logf(nil, "Serving remote control on %s", s.URL())
|
fs.Logf(nil, "Serving remote control on %s", s.URL())
|
||||||
// Open the files in the browser if set
|
// Open the files in the browser if set
|
||||||
if s.files != nil {
|
if s.files != nil {
|
||||||
_ = open.Start(s.URL())
|
openURL, err := url.Parse(s.URL())
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "invalid serving URL")
|
||||||
|
}
|
||||||
|
// Add username, password into the URL if they are set
|
||||||
|
user, pass := s.opt.HTTPOptions.BasicUser, s.opt.HTTPOptions.BasicPass
|
||||||
|
if user != "" || pass != "" {
|
||||||
|
openURL.User = url.UserPassword(user, pass)
|
||||||
|
}
|
||||||
|
_ = open.Start(openURL.String())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue