mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
* feat: api access control * feat(web): granular api access controls * fix test * fix e2e test * fix: lint * pr feedback * merge main + new design * finalize styling --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
40 lines
1,015 B
TypeScript
40 lines
1,015 B
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { ArrayMinSize, IsEnum, IsNotEmpty, IsString } from 'class-validator';
|
|
import { Permission } from 'src/enum';
|
|
import { Optional } from 'src/validation';
|
|
export class APIKeyCreateDto {
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@Optional()
|
|
name?: string;
|
|
|
|
@IsEnum(Permission, { each: true })
|
|
@ApiProperty({ enum: Permission, enumName: 'Permission', isArray: true })
|
|
@ArrayMinSize(1)
|
|
permissions!: Permission[];
|
|
}
|
|
|
|
export class APIKeyUpdateDto {
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
name!: string;
|
|
|
|
@IsEnum(Permission, { each: true })
|
|
@ApiProperty({ enum: Permission, enumName: 'Permission', isArray: true })
|
|
@ArrayMinSize(1)
|
|
permissions!: Permission[];
|
|
}
|
|
|
|
export class APIKeyCreateResponseDto {
|
|
secret!: string;
|
|
apiKey!: APIKeyResponseDto;
|
|
}
|
|
|
|
export class APIKeyResponseDto {
|
|
id!: string;
|
|
name!: string;
|
|
createdAt!: Date;
|
|
updatedAt!: Date;
|
|
@ApiProperty({ enum: Permission, enumName: 'Permission', isArray: true })
|
|
permissions!: Permission[];
|
|
}
|