Multiple roles using @PreAuthorize

You can create a custom annotation to validate many roles and conditions. P.e.: @Retention(RetentionPolicy.RUNTIME) @PreAuthorize(“hasRole(T(com.bs.dmsbox.api.constants.RoleConstants).ROLE_AGENT) ” + “|| hasRole(T(com.bs.dmsbox.api.constants.RoleConstants).ROLE_ADMIN)” + “|| (hasRole(T(com.bs.dmsbox.api.constants.RoleConstants).ROLE_CUSTOMER) && #userId == principal.username)”) public @interface IsAuthenticatedAsAgentOrCustomerIsUserId { } Then, you can use this annotation as below: @IsAuthenticatedAsAgentOrCustomerIsUserId Folder findByUserIdAndType(@Param(“userId”) String userId, @Param(“typeId”) FolderType id); This annotation validate that user logged as role … Read more

How to set the max size of upload file

Also in Spring boot 1.4, you can add following lines to your application.properties to set the file size limit: spring.http.multipart.max-file-size=128KB spring.http.multipart.max-request-size=128KB for spring boot 2.x and above its spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-request-size=10MB Worked for me. Source: https://spring.io/guides/gs/uploading-files/ UPDATE: Somebody asked the differences between the two properties. Below are the formal definitions: MaxFileSize: The maximum size allowed for … Read more