fix: comprehensive portal audit - bugfixes, performance, security, logo

Critical bugs:
- Fix bulk-download: UUID idempotency key, input validation, error handling, parallel asset validation
- Fix leuchtkasten 404 link -> album page with search
- Fix revalidatePath [id] -> [albumId]
- Fix PDF crash on null invoiceNumber

Logo:
- Fix dimensions (1000x1000), dark mode support (logo-white.png), max-height constraint

UI bugs:
- Fix unsafe Date method calls (6 files)
- Fix album UUID shown instead of name in catalog
- Fix global search downloads (albumId from asset)
- Add null guard for lightbox asset map

Performance:
- Parallelize admin dashboard queries (Promise.all)
- Lazy-load recharts via next/dynamic
- Add thumbnail caching headers (24h + ETag)
- Reduce duplicate Immich API calls in usage service
- Add DB index on usages(createdAt)
- Add optimizePackageImports for lucide-react, recharts

Security:
- Input validation on bulk-download (max 100 items, UUID format, purpose length)
- Verify security headers present in next.config.ts
This commit is contained in:
Leon Tonhäuser committed 2026-08-11 11:50:12 +02:00
1 parent 0576d946c5
commit d9d69ed861
21 files changed
+229 -153

No files matched your search

@@ -47,9 +47,9 @@ export function createThumbnailHandler(dependencies: ThumbnailHandlerDependencie
const thumbnail = await dependencies.immich.getThumbnail(assetId);
if (access.kind === "editorial") {
return watermarkedThumbnailResponse(thumbnail);
return watermarkedThumbnailResponse(thumbnail, assetId);
}
return thumbnailResponse(thumbnail);
return thumbnailResponse(thumbnail, assetId);
} catch (err) {
return genericNotFound();
}
@@ -101,11 +101,12 @@ async function isAdminAlbumCover(
return album.albumThumbnailAssetId === assetId;
}
function thumbnailResponse(thumbnail: ImmichBinary): Response {
function thumbnailResponse(thumbnail: ImmichBinary, assetId: string): Response {
const responseHeaders = new Headers({
"cache-control": "private, no-store",
"cache-control": "private, max-age=86400, stale-while-revalidate=604800",
"content-type": thumbnail.contentType,
"x-content-type-options": "nosniff",
"etag": `"${assetId}"`,
});
if (thumbnail.contentLength !== null) {
responseHeaders.set("content-length", String(thumbnail.contentLength));
@@ -117,7 +118,7 @@ function genericNotFound(): Response {
return new Response(null, { status: 404 });
}
async function watermarkedThumbnailResponse(thumbnail: ImmichBinary): Promise<Response> {
async function watermarkedThumbnailResponse(thumbnail: ImmichBinary, assetId: string): Promise<Response> {
const reader = thumbnail.body.getReader();
const chunks: Uint8Array[] = [];
while (true) {
@@ -150,10 +151,11 @@ async function watermarkedThumbnailResponse(thumbnail: ImmichBinary): Promise<Re
.toBuffer();
const responseHeaders = new Headers({
"cache-control": "private, no-store",
"cache-control": "private, max-age=86400, stale-while-revalidate=604800",
"content-type": "image/webp",
"content-length": String(watermarked.length),
"x-content-type-options": "nosniff",
"etag": `"${assetId}-watermark"`,
});
return new Response(watermarked, { headers: responseHeaders });