diff --git a/src/main/kotlin/dev/usbharu/hideout/application/config/SecurityConfig.kt b/src/main/kotlin/dev/usbharu/hideout/application/config/SecurityConfig.kt index 85f22367..59caf58d 100644 --- a/src/main/kotlin/dev/usbharu/hideout/application/config/SecurityConfig.kt +++ b/src/main/kotlin/dev/usbharu/hideout/application/config/SecurityConfig.kt @@ -187,6 +187,8 @@ class SecurityConfig { authorize("/auth/sign_up", hasRole("ANONYMOUS")) authorize(GET, "/files", permitAll) + authorize(GET, "/users/*/icon.jpg", permitAll) + authorize(GET, "/users/*/header.jpg", permitAll) authorize(GET, "/api/v1/accounts/verify_credentials", hasAnyScope("read", "read:accounts")) diff --git a/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/media/LocalFileController.kt b/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/media/LocalFileController.kt index a7c4032e..772e7b46 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/media/LocalFileController.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/media/LocalFileController.kt @@ -3,6 +3,7 @@ package dev.usbharu.hideout.core.interfaces.api.media import dev.usbharu.hideout.application.config.LocalStorageConfig import dev.usbharu.hideout.core.service.media.FileTypeDeterminationService import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty +import org.springframework.core.io.ClassPathResource import org.springframework.core.io.PathResource import org.springframework.core.io.Resource import org.springframework.http.MediaType @@ -37,4 +38,15 @@ class LocalFileController( .contentLength(pathResource.contentLength()) .body(pathResource) } + + @GetMapping("/users/{user}/icon.jpg", "/users/{user}/header.jpg") + fun icons(): ResponseEntity { + + val pathResource = ClassPathResource("icon.png") + return ResponseEntity + .ok() + .contentType(MediaType.IMAGE_PNG) + .contentLength(pathResource.contentLength()) + .body(pathResource) + } }