-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(query): deprecate explain without master key #7521
base: alpha
Are you sure you want to change the base?
Changes from all commits
2359f6e
b9e2706
882861b
d27d3f6
3577c96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ The following is a list of deprecations, according to the [Deprecation Policy](h | |
|-------------------------------------------------|----------------------------------------------------------------------|---------------------------------|---------------------------------|-----------------------|-------| | ||
| Native MongoDB syntax in aggregation pipeline | [#7338](https://github.com/parse-community/parse-server/issues/7338) | 5.0.0 (2022) | 6.0.0 (2023) | deprecated | - | | ||
| Config option `directAccess` defaults to `true` | [#6636](https://github.com/parse-community/parse-server/pull/6636) | 5.0.0 (2022) | 6.0.0 (2023) | deprecated | - | | ||
| `explain` queries used by non-master users | [#7519](https://github.com/parse-community/parse-server/issues/7519) | 5.0.0 (2022) | 6.0.0 (2023) | deprecated | - | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you rephrase that as
And can you add an ID for this deprecation, after you merge master into this PR |
||
|
||
[i_deprecation]: ## "The version and date of the deprecation." | ||
[i_removal]: ## "The version and date of the planned removal." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5218,4 +5218,36 @@ describe('Parse.Query testing', () => { | |
// Validate | ||
expect(result.executionStats).not.toBeUndefined(); | ||
}); | ||
|
||
xit('users cannot use explain queries', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is in preparation for after the deprecation? Could you add a short comment above?
Assuming that |
||
// Create an object | ||
const obj = new TestObject({ foo: 'baz', hello: 'world' }); | ||
await obj.save(); | ||
// Query TestObject with explain. | ||
const query = new Parse.Query('TestObject'); | ||
query.equalTo('objectId', obj.id); | ||
query.explain(); | ||
try { | ||
await query.find(); | ||
fail('even non-master users can use explain'); | ||
} catch (e) { | ||
equal(e.code, Parse.Error.OPERATION_FORBIDDEN); | ||
equal(e.message, 'Cannot explain'); | ||
} | ||
try { | ||
await new Parse.Query('TestObject').explain().get(obj.id); | ||
fail('even non-master users can use explain'); | ||
} catch (e) { | ||
equal(e.code, Parse.Error.OPERATION_FORBIDDEN); | ||
equal(e.message, 'Cannot explain'); | ||
} | ||
}).pend('Disabled until non-master explains are disabled'); | ||
it('the master key can use explain queries', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newline between tests |
||
const obj = new TestObject({ foo: 'baz', hello: 'world' }); | ||
await obj.save(); | ||
const query = new Parse.Query('TestObject'); | ||
query.equalTo('objectId', obj.id); | ||
query.explain(); | ||
await query.find({ useMasterKey: true }); // Must not throw | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ var Parse = require('parse/node').Parse; | |
var RestQuery = require('./RestQuery'); | ||
var RestWrite = require('./RestWrite'); | ||
var triggers = require('./triggers'); | ||
import Deprecator from './Deprecator/Deprecator'; | ||
|
||
function checkTriggers(className, config, types) { | ||
return types.some(triggerType => { | ||
|
@@ -26,6 +27,12 @@ function checkLiveQuery(className, config) { | |
// Returns a promise for an object with optional keys 'results' and 'count'. | ||
function find(config, auth, className, restWhere, restOptions, clientSDK, context) { | ||
enforceRoleSecurity('find', className, auth); | ||
if (restOptions && restOptions.explain && !auth.isMaster) { | ||
//throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, 'Cannot explain'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a comment here please, similar to the one above |
||
Deprecator.logRuntimeDeprecation({ | ||
usage: 'The use of explain queries by non-master users', | ||
}); | ||
} | ||
return triggers | ||
.maybeRunQueryTrigger( | ||
triggers.Types.beforeFind, | ||
|
@@ -57,6 +64,12 @@ function find(config, auth, className, restWhere, restOptions, clientSDK, contex | |
const get = (config, auth, className, objectId, restOptions, clientSDK, context) => { | ||
var restWhere = { objectId }; | ||
enforceRoleSecurity('get', className, auth); | ||
if (restOptions && restOptions.explain && !auth.isMaster) { | ||
//throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, 'Cannot explain'); | ||
Deprecator.logRuntimeDeprecation({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a comment here please, similar to the one above |
||
usage: 'The use of explain queries by non-master users', | ||
}); | ||
} | ||
return triggers | ||
.maybeRunQueryTrigger( | ||
triggers.Types.beforeFind, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rephrase this as: