Merge pull request #295 from jonvdveen/fix/immich-v3-api-key-permissions
fix: API key permissions for Immich v3 (albumAsset.*, tag.asset) and honor "all" in key validation
This commit is contained in:
@@ -8,7 +8,8 @@ export const IMPORT_PERMISSIONS: Permission[] = [
|
||||
{ name: "asset.upload", description: "Upload new assets" },
|
||||
{ name: "album.read", description: "Read album data" },
|
||||
{ name: "album.create", description: "Create new albums" },
|
||||
{ name: "album.update", description: "Add assets to albums" },
|
||||
{ name: "album.update", description: "Update album metadata" },
|
||||
{ name: "albumAsset.create", description: "Add assets to albums" },
|
||||
{ name: "tag.create", description: "Tag imported assets" },
|
||||
{ name: "tag.asset", description: "Assign tags to assets" },
|
||||
];
|
||||
@@ -18,8 +19,11 @@ export const WORKFLOW_PERMISSIONS: Permission[] = [
|
||||
{ name: "asset.update", description: "Favorite, archive, update metadata" },
|
||||
{ name: "album.read", description: "Read album data" },
|
||||
{ name: "album.create", description: "Create new albums" },
|
||||
{ name: "album.update", description: "Add/remove assets from albums" },
|
||||
{ name: "tag.create", description: "Create and assign tags" },
|
||||
{ name: "album.update", description: "Update album metadata" },
|
||||
{ name: "albumAsset.create", description: "Add assets to albums" },
|
||||
{ name: "albumAsset.delete", description: "Remove assets from albums" },
|
||||
{ name: "tag.create", description: "Create tags" },
|
||||
{ name: "tag.asset", description: "Assign tags to assets" },
|
||||
];
|
||||
|
||||
export const getPermissionNames = (permissions: Permission[]): string[] =>
|
||||
|
||||
@@ -30,7 +30,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
const keyData = await keyRes.json();
|
||||
const granted: string[] = keyData.permissions ?? [];
|
||||
const missing = REQUIRED_PERMISSIONS.filter((p) => !granted.includes(p));
|
||||
// A key created with the "All" checkbox reports its permissions as ["all"],
|
||||
// which grants every permission without listing them individually.
|
||||
const missing = granted.includes("all")
|
||||
? []
|
||||
: REQUIRED_PERMISSIONS.filter((p) => !granted.includes(p));
|
||||
|
||||
return res.status(200).json({
|
||||
valid: missing.length === 0,
|
||||
|
||||
Reference in New Issue
Block a user