<fileUploadConfiguration>
<item>
<path>jpegPhoto</path>
<checkContentType>true</checkContentType>
<allowedContentType>image/jpeg</allowedContentType>
<allowedContentType>image/png</allowedContentType>
</item>
</fileUploadConfiguration>
File upload configuration
This page describes how to configure file upload validation in midPoint.
Introduction
When you upload files to midPoint, the system validates that the file type matches the declared type. This means that if you upload a file with the .PNG extension, for example, the system will check if the uploaded file is indeed a PNG.
This prevents users from uploading files with incorrect or misleading file extensions, which could lead to security vulnerabilities or data integrity issues.
What is validated
MidPoint validates a number of standard file types, including images and documents.
There are the following pre-configured validation areas for file uploads, represented by specific properties:
-
For users, roles, services and orgs, i.e., subtypes of
FocusType- The system allows uploading JPEG and PNG image files.
For example, this means that you can only upload JPEG and PNG files as user profile pictures by default.
This configuration is represented by thejpegPhotoproperty in the schema.Default validation configuration forjpegPhoto: -
For cases - By default, the system does not restrict file uploads. This configuration is represented by the
output/evidenceproperty in the schema.
These predefined validation areas can be customized as described below.
Configuration options
You can customize the configuration of the pre-defined jpegPhoto and output/evidence properties.
For example, you can broaden or restrict upload to other formats, or convert the uploaded image to a different format.
File upload configuration is controlled by fileUploadConfiguration in the Admin GUI configuration.
The following parameters are accepted:
-
checkContentType- If set totrue, the system checks the content type of the uploaded file against the content types defined byallowedContentType. If set tofalse, the system does not perform this check. -
allowedContentType- Specifies the allowed content types for the uploaded file. You can specify multiple allowed content types by adding a separateallowedContentTypeelement for each content type.
See the complete list of supported content types with theirallowedContentTypevalues:Table 1. Supported file types File type allowedContentTypevalueJPEG
image/jpegPNG
image/pngPDF
application/pdfDOC
application/mswordXLS
application/vnd.ms-excelPPT
application/vnd.ms-powerpointDOCX
application/vnd.openxmlformats-officedocument.wordprocessingml.documentXLSX
application/vnd.openxmlformats-officedocument.spreadsheetml.sheetPPTX
application/vnd.openxmlformats-officedocument.presentationml.presentationODT
application/vnd.oasis.opendocument.textODS
application/vnd.oasis.opendocument.spreadsheetODP
application/vnd.oasis.opendocument.presentation -
convertImageTo- Specifies the image format to which the uploaded image should be converted. The valid values for this parameter arejpegandpng. -
stripMetadata- If set totrue, the system removes metadata from the uploaded image file. If set tofalse, the system retains the metadata in the uploaded image file.
Configure file upload validation
-
Go to System > Admin GUI Configuration.
-
Click Edit raw.
-
In the
adminGUIConfigurationsection, add your configuration. For example, the following enables uploading JPEG and PNG files and strips metadata from the uploaded images for thejpegPhotoproperty, and allows uploading PDF files for theoutput/evidenceproperty:Example file upload configuration<fileUploadConfiguration> <item id="352"> <path>jpegPhoto</path> <checkContentType>true</checkContentType> <allowedContentType>image/jpeg</allowedContentType> <allowedContentType>image/png</allowedContentType> <stripMetadata>true</stripMetadata> </item> <item id="353"> <path>output/evidence</path> <checkContentType>true</checkContentType> <allowedContentType>application/pdf</allowedContentType> </item> </fileUploadConfiguration> -
Click Save.