mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 07:29:35 +01:00
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
@ -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
|
||||
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.
|
||||
|
||||
### --rc-no-auth
|
||||
|
@ -69,7 +69,16 @@ func (s *Server) Serve() error {
|
||||
fs.Logf(nil, "Serving remote control on %s", s.URL())
|
||||
// Open the files in the browser if set
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user