From a614459485be169602de35bc4b061c6211fef381 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Wed, 6 Dec 2023 21:45:14 +0900 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=9A=AB=E5=AE=9A=E3=81=A7=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E3=83=BC=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=82=92=E8=BF=94=E5=8D=B4=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hideout/application/config/SecurityConfig.kt | 2 ++ .../core/interfaces/api/media/LocalFileController.kt | 12 ++++++++++++ 2 files changed, 14 insertions(+) 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) + } }