From 0e85db1f1db88facb81aaecb034fd85ea1b904b9 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Fri, 8 Aug 2025 18:04:17 +0900 Subject: [PATCH] ... --- .../back/lun/configs/BumsInterceptor.kt | 1 + .../back/lun/configs/SecurityConfig.kt | 15 +++++-- .../back/lun/controllers/UserController.kt | 3 +- src/main/resources/static/js/blog.js | 42 ++++++++++++------- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/configs/BumsInterceptor.kt b/src/main/kotlin/kr/lunaticbum/back/lun/configs/BumsInterceptor.kt index 0c65bcc..bd66820 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/configs/BumsInterceptor.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/configs/BumsInterceptor.kt @@ -58,6 +58,7 @@ class BumsInterceptor : HandlerInterceptor { modelAndView.modelMap.put(ApiKeyWordKey, "Def") println("modelMap 내용 추가 완료: ${modelAndView.modelMap}") } else { + println("modelAndView가 null이라 모델에 값 추가 불가") } diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/configs/SecurityConfig.kt b/src/main/kotlin/kr/lunaticbum/back/lun/configs/SecurityConfig.kt index 54fe4ed..ad23349 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/configs/SecurityConfig.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/configs/SecurityConfig.kt @@ -16,6 +16,7 @@ import org.springframework.security.authentication.AuthenticationManager import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity +import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.core.AuthenticationException import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder @@ -34,12 +35,20 @@ class SecurityConfig( @Autowired lateinit var logService: LogService + @Bean + fun webSecurityCustomizer(): WebSecurityCustomizer { + return WebSecurityCustomizer { web -> + web.ignoring().requestMatchers("/blog/post/images/**") + } + } + @Bean fun filterChain(http: HttpSecurity): SecurityFilterChain { http.csrf { csrf -> csrf.ignoringRequestMatchers( "/user/login.bjx", "/user/joinUser.bjx","/tlg/repotToMe.bjx", - "/blog/post/imageUpload.bjx", "/blog/post.bjx" + "/blog/post/imageUpload.bjx", "/blog/post.bjx", + "/blog/post/images/**" ) // 여기 예외 추가 }.authorizeHttpRequests { auth -> auth @@ -64,8 +73,8 @@ class SecurityConfig( .tokenValiditySeconds(60 * 60 * 24 * 7) // 7일간 유효 .userDetailsService(userManager) // 사용자 정보 서비스 지정 }.logout { logout -> - logout.logoutUrl("/user/logout.bs").logoutSuccessUrl("/").permitAll() - } + logout.logoutUrl("/user/logout.bs").logoutSuccessUrl("/").permitAll() + } return http.build() } diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/UserController.kt b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/UserController.kt index 3ebadf5..0cc8740 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/UserController.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/UserController.kt @@ -138,8 +138,7 @@ class UserController { this.isOk = lResultCode == 0 this.resultCode = lResultCode this.resultMsg = lResultMsg - this.token = setTokenToCookie(JwtRule.ACCESS_PREFIX.value, tokenData?.tokenKey ?: "", globalEvv.ACCESS_EXPIRATION / 1000).toString().replace("access=","") - this.refresh = setTokenToCookie(JwtRule.REFRESH_PREFIX.value, tokenData?.refreshToken ?: "", globalEvv.REFRESH_EXPIRATION / 1000).toString().replace("refresh=","") + this.token = if (remeberMe) "OK" else "" }).apply { } diff --git a/src/main/resources/static/js/blog.js b/src/main/resources/static/js/blog.js index aab98a1..b4c90d9 100644 --- a/src/main/resources/static/js/blog.js +++ b/src/main/resources/static/js/blog.js @@ -99,20 +99,34 @@ function save() { } function selectLocalImage() { - const input = document.createElement('input'); - input.setAttribute('type', 'file'); - input.setAttribute('accept', 'image/*'); - input.click(); - console.log("on selectLocalImage") - input.onchange = () => { - const file = input.files[0]; - console.log("on selectLocalImage File", file); - if (!file || !file.type.startsWith('image/')) { - console.warn('이미지 파일만 업로드 가능합니다.'); - return; - } - uploadImage(file); - }; + // 이미지 URL 입력 받기 + const url = prompt("이미지 URL을 입력하거나 빈칸으로 두시면 파일 업로드를 합니다."); + + if (url) { + // URL이 입력된 경우 이미지 삽입 + const range = quill.getSelection(true); + quill.insertEmbed(range.index, 'image', url); + quill.setSelection(range.index + 1); + } else { + // URL이 없거나 취소한 경우 파일 업로드 처리 + const input = document.createElement('input'); + input.setAttribute('type', 'file'); + input.setAttribute('accept', 'image/*'); + input.click(); + + input.onchange = async () => { + const file = input.files[0]; + if (file) { + const file = input.files[0]; + console.log("on selectLocalImage File", file); + if (!file || !file.type.startsWith('image/')) { + console.warn('이미지 파일만 업로드 가능합니다.'); + return; + } + uploadImage(file); + } + }; + } } function uploadImage(blob) {