mirror of
https://github.com/directus/directus.git
synced 2026-01-28 07:48:04 -05:00
Check if is UUID before check permissions (#10837)
On checking permissions it reads the value from database, so we need to verify if is UUID before this process
This commit is contained in:
@@ -44,10 +44,6 @@ export class AssetsService {
|
||||
|
||||
const systemPublicKeys = Object.values(publicSettings || {});
|
||||
|
||||
if (systemPublicKeys.includes(id) === false && this.accountability?.admin !== true) {
|
||||
await this.authorizationService.checkAccess('read', 'directus_files', id);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a little annoying. Postgres will error out if you're trying to search in `where`
|
||||
* with a wrong type. In case of directus_files where id is a uuid, we'll have to verify the
|
||||
@@ -57,6 +53,10 @@ export class AssetsService {
|
||||
|
||||
if (isValidUUID === false) throw new ForbiddenException();
|
||||
|
||||
if (systemPublicKeys.includes(id) === false && this.accountability?.admin !== true) {
|
||||
await this.authorizationService.checkAccess('read', 'directus_files', id);
|
||||
}
|
||||
|
||||
const file = (await this.knex.select('*').from('directus_files').where({ id }).first()) as File;
|
||||
|
||||
if (!file) throw new ForbiddenException();
|
||||
|
||||
Reference in New Issue
Block a user