This commit is contained in:
lunaticbum 2025-08-08 18:04:17 +09:00
parent 9cb482ac6a
commit 0e85db1f1d
4 changed files with 42 additions and 19 deletions

View File

@ -58,6 +58,7 @@ class BumsInterceptor : HandlerInterceptor {
modelAndView.modelMap.put(ApiKeyWordKey, "Def") modelAndView.modelMap.put(ApiKeyWordKey, "Def")
println("modelMap 내용 추가 완료: ${modelAndView.modelMap}") println("modelMap 내용 추가 완료: ${modelAndView.modelMap}")
} else { } else {
println("modelAndView가 null이라 모델에 값 추가 불가") println("modelAndView가 null이라 모델에 값 추가 불가")
} }

View File

@ -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.authentication.builders.AuthenticationManagerBuilder
import org.springframework.security.config.annotation.web.builders.HttpSecurity 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.EnableWebSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer
import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.config.http.SessionCreationPolicy
import org.springframework.security.core.AuthenticationException import org.springframework.security.core.AuthenticationException
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
@ -34,12 +35,20 @@ class SecurityConfig(
@Autowired @Autowired
lateinit var logService: LogService lateinit var logService: LogService
@Bean
fun webSecurityCustomizer(): WebSecurityCustomizer {
return WebSecurityCustomizer { web ->
web.ignoring().requestMatchers("/blog/post/images/**")
}
}
@Bean @Bean
fun filterChain(http: HttpSecurity): SecurityFilterChain { fun filterChain(http: HttpSecurity): SecurityFilterChain {
http.csrf { csrf -> http.csrf { csrf ->
csrf.ignoringRequestMatchers( csrf.ignoringRequestMatchers(
"/user/login.bjx", "/user/joinUser.bjx","/tlg/repotToMe.bjx", "/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 -> }.authorizeHttpRequests { auth ->
auth auth
@ -64,8 +73,8 @@ class SecurityConfig(
.tokenValiditySeconds(60 * 60 * 24 * 7) // 7일간 유효 .tokenValiditySeconds(60 * 60 * 24 * 7) // 7일간 유효
.userDetailsService(userManager) // 사용자 정보 서비스 지정 .userDetailsService(userManager) // 사용자 정보 서비스 지정
}.logout { logout -> }.logout { logout ->
logout.logoutUrl("/user/logout.bs").logoutSuccessUrl("/").permitAll() logout.logoutUrl("/user/logout.bs").logoutSuccessUrl("/").permitAll()
} }
return http.build() return http.build()
} }

View File

@ -138,8 +138,7 @@ class UserController {
this.isOk = lResultCode == 0 this.isOk = lResultCode == 0
this.resultCode = lResultCode this.resultCode = lResultCode
this.resultMsg = lResultMsg this.resultMsg = lResultMsg
this.token = setTokenToCookie(JwtRule.ACCESS_PREFIX.value, tokenData?.tokenKey ?: "", globalEvv.ACCESS_EXPIRATION / 1000).toString().replace("access=","") this.token = if (remeberMe) "OK" else ""
this.refresh = setTokenToCookie(JwtRule.REFRESH_PREFIX.value, tokenData?.refreshToken ?: "", globalEvv.REFRESH_EXPIRATION / 1000).toString().replace("refresh=","")
}).apply { }).apply {
} }

View File

@ -99,20 +99,34 @@ function save() {
} }
function selectLocalImage() { function selectLocalImage() {
const input = document.createElement('input'); // 이미지 URL 입력 받기
input.setAttribute('type', 'file'); const url = prompt("이미지 URL을 입력하거나 빈칸으로 두시면 파일 업로드를 합니다.");
input.setAttribute('accept', 'image/*');
input.click(); if (url) {
console.log("on selectLocalImage") // URL이 입력된 경우 이미지 삽입
input.onchange = () => { const range = quill.getSelection(true);
const file = input.files[0]; quill.insertEmbed(range.index, 'image', url);
console.log("on selectLocalImage File", file); quill.setSelection(range.index + 1);
if (!file || !file.type.startsWith('image/')) { } else {
console.warn('이미지 파일만 업로드 가능합니다.'); // URL이 없거나 취소한 경우 파일 업로드 처리
return; const input = document.createElement('input');
} input.setAttribute('type', 'file');
uploadImage(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) { function uploadImage(blob) {