mirror of
https://github.com/directus/directus.git
synced 2026-01-30 20:28:00 -05:00
Check permissions before aggregating fields
This commit is contained in:
@@ -98,6 +98,16 @@ export class AuthorizationService {
|
||||
|
||||
const allowedFields = permissions.fields || [];
|
||||
|
||||
if (ast.query.aggregate && allowedFields.includes('*') === false) {
|
||||
for (const [_operation, aliasMap] of Object.entries(ast.query.aggregate)) {
|
||||
if (!aliasMap) continue;
|
||||
|
||||
for (const [column, _alias] of Object.entries(aliasMap)) {
|
||||
if (allowedFields.includes(column) === false) throw new ForbiddenException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const childNode of ast.children) {
|
||||
if (childNode.type !== 'field') {
|
||||
validateFields(childNode);
|
||||
|
||||
Reference in New Issue
Block a user