Skip to content

Commit dee35d2

Browse files
committed
wip
1 parent c9df14d commit dee35d2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

spec/JobSchedule.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
describe('JobSchedule', () => {
3+
it('should create _JobSchedule with masterKey', (done) => {
4+
const jobSchedule = new Parse.Object('_JobSchedule');
5+
jobSchedule.set({
6+
'jobName': 'MY Cool Job'
7+
});
8+
jobSchedule.save(null, {useMasterKey: true}).then(() => {
9+
done();
10+
})
11+
.catch(done.fail);
12+
});
13+
14+
it('should fail creating _JobSchedule without masterKey', (done) => {
15+
const jobSchedule = new Parse.Object('_JobSchedule');
16+
jobSchedule.set({
17+
'jobName': 'SomeJob'
18+
});
19+
jobSchedule.save(null).then(done.fail)
20+
.catch(done);
21+
});
22+
});

src/rest.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,15 @@ function update(config, auth, className, restWhere, restObject, clientSDK) {
134134
});
135135
}
136136

137+
const classesWithMasterOnlyAccess = ['_PushStatus', '_Hooks', '_GlobalConfig', '_JobStatus', '_JobSchedule'];
137138
// Disallowing access to the _Role collection except by master key
138139
function enforceRoleSecurity(method, className, auth) {
140+
if (classesWithMasterOnlyAccess.indexOf(className) > -1 && !auth.isMaster) {
141+
const error = new Error();
142+
error.status = 403;
143+
error.message = "unauthorized: master key is required";
144+
throw error;
145+
}
139146
if (className === '_Installation' && !auth.isMaster) {
140147
if (method === 'delete' || method === 'find') {
141148
const error = `Clients aren't allowed to perform the ${method} operation on the installation collection.`

0 commit comments

Comments
 (0)