1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-09-20 15:34:03 +00:00

Throw an exception in possibleTenantSymlinks if the disk is not tenant-aware

When a disk in url_override and root_override is absent from tenancy.filesystem.disks, FilesystemTenancyBootstrapper leaves its root unchanged, possibleTenantSymlinks allows creating a symlink for that unscoped disk (= a disk with a central root), which can expose shared files.

Fixed by throwing an exception in possibleTenantSymlinks saying that the disk should be tenant-aware (= included in the tenancy.filesystem.disks config).
This commit is contained in:
lukinovec 2026-08-19 10:35:07 +02:00 committed by Samuel Stancl
parent b6e6aa634c
commit 0eb2cf18a4

View file

@ -50,6 +50,12 @@ trait DealsWithTenantSymlinks
throw new Exception("Disk $disk is not a local disk. Only local disks can be symlinked.");
}
if (! in_array($disk, config('tenancy.filesystem.disks'), true)) {
// The bootstrapper only scopes disks listed in tenancy.filesystem.disks. Without that,
// the disk root stays central, and the symlink of every tenant would point to it.
throw new Exception("Disk $disk is not tenant-aware. Add it to the tenancy.filesystem.disks config to make its root tenant-specific.");
}
$publicPath = str_replace('%tenant%', (string) $tenantKey, $publicPath);
$symlinks[public_path($publicPath)] = $tenantDisks[$disk]['root'];