Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

rc: make job/status and job/list require authentication

Nick Craig-Wood939f82d908c1
diff --git a/fs/rc/jobs/job.go b/fs/rc/jobs/job.go
index 8f5d365a1..b4ef2acca 100644
--- a/fs/rc/jobs/job.go
+++ b/fs/rc/jobs/job.go
@@ -346,10 +346,9 @@ func GetJobID(ctx context.Context) (jobID int64, ok bool) {
func init() {
rc.Add(rc.Call{
- Path: "job/status",
- NoAuth: true,
- Fn: rcJobStatus,
- Title: "Reads the status of the job ID",
+ Path: "job/status",
+ Fn: rcJobStatus,
+ Title: "Reads the status of the job ID",
Help: `Parameters:
- jobid - id of the job (integer).
@@ -393,10 +392,9 @@ func rcJobStatus(ctx context.Context, in rc.Params) (out rc.Params, err error) {
func init() {
rc.Add(rc.Call{
- Path: "job/list",
- NoAuth: true,
- Fn: rcJobList,
- Title: "Lists the IDs of the running jobs",
+ Path: "job/list",
+ Fn: rcJobList,
+ Title: "Lists the IDs of the running jobs",
Help: `Parameters: None.
Results:
diff --git a/fs/rc/rcserver/rcserver_test.go b/fs/rc/rcserver/rcserver_test.go
index 533dbcb28..1a5a67ffa 100644
--- a/fs/rc/rcserver/rcserver_test.go
+++ b/fs/rc/rcserver/rcserver_test.go
@@ -910,6 +910,48 @@ func TestAuthRequired(t *testing.T) {
testServer(t, tests, &opt)
}
+// job/status returns the output of any job so it must need
+// authentication, e.g. so an unauthenticated user can't read the
+// output of config/dump started with _async by an authenticated one.
+func TestJobAuthRequired(t *testing.T) {
+ tests := []testRun{{
+ Name: "status",
+ URL: "job/status",
+ Method: "POST",
+ Body: `{"jobid":1}`,
+ ContentType: "application/json",
+ Status: http.StatusForbidden,
+ Expected: `{
+ "error": "authentication must be set up on the rc server to use \"job/status\" or the --rc-no-auth flag must be in use",
+ "input": {
+ "jobid": 1
+ },
+ "path": "job/status",
+ "status": 403
+}
+`,
+ }, {
+ Name: "list",
+ URL: "job/list",
+ Method: "POST",
+ Body: `{}`,
+ ContentType: "application/json",
+ Status: http.StatusForbidden,
+ Expected: `{
+ "error": "authentication must be set up on the rc server to use \"job/list\" or the --rc-no-auth flag must be in use",
+ "input": {},
+ "path": "job/list",
+ "status": 403
+}
+`,
+ }}
+ opt := newTestOpt()
+ opt.Serve = false
+ opt.Files = ""
+ opt.NoAuth = false
+ testServer(t, tests, &opt)
+}
+
func TestNoAuth(t *testing.T) {
tests := []testRun{{
Name: "auth",