개발관련
-
JWT 로그인 oauth2ResourceServer 설정개발관련/참고 2024. 11. 26. 18:54
대용량 트래픽 처리 강의를 따라하다가 chatGPT가 스프링 시큐리티 설정에서 JWT로그인 처리를 토큰필터 추가가 아닌, oauth2ResourceServer로 작성해줘서 설정한 내용을 기록.아래 표는 chatGPT가 알려준 비교점을 복붙함.특징oauth2ResourceServer() 설정토큰 필터 추가구현 편의성Spring Security가 JWT 검증 로직을 자동 처리모든 작업을 수동으로 구현해야 함표준 준수OAuth2 명세 준수명세를 따를 필요 없음확장성Spring Security의 다양한 확장 기능 활용 가능완전한 커스터마이징 가능복잡도간단 (기본 기능 사용 시 적합)복잡 (맞춤형 요구사항 처리 시 적합)적합한 사용 사례OAuth2/JWT 기반 인증 (OAuth2 서버와 통합)커스텀 인증 메커니즘..
-
토이프로젝트 배포 메모장개발관련/삽질 2024. 10. 5. 19:03
1. vue 프로젝트 AWS S3로 배포하기S3 버킷 만들기는 검색하거나, 그냥 진행해도 상관없음. vue 프로젝트 빌드 후 /dist 디렉을 모두 업로드하고, 정적 웹 사이트 호스팅 이후 문제점들 메모앤드포인트 접근 시 403 Forbidden, Accessdenied 문제. - 정책문제로 검색 후 해결.프론트서버를 사용자화면, 스토어관리자화면 2개를 구성. - 버킷 2개 만들어서 사용하는걸로 해결.2. 스프링부트 프로젝트 EC2에 배포하기스토어api서버, 유저api서버 2개를 어떻게 같이 배포할까 고민.도커를 설치해서 같이 배포하기로 결정.기록용으로 Dockerfile, docker-compose.yaml 참조# Java 환경이 있는 Docker 이미지를 기반으로 사용FROM openjdk:17-jd..
-
코틀린 스프링부트 JWT refreshToken 설정 관련(feat. Filter)개발관련/삽질 2024. 9. 9. 01:44
시큐리티 설정에서 들어오는 jwt토큰을 체크하는 필터를 추가했다.@Beanfun filterChain(httpSecurity: HttpSecurity): SecurityFilterChain { return httpSecurity ... .addFilterBefore( JwtAuthFilter(tokenBusiness, userDetailsService), UsernamePasswordAuthenticationFilter::class.java ) .build()} 그리고 기존 토큰을 발급하는 로직에 테스트를 위해서 accessToken(1)과 refreshToken(12) 각각 더하는 시간을 시간이 아닌 분으로 ..
-
Winodows에서 도커 설치 관련 path 설정개발관련/참고 2024. 7. 24. 17:29
윈도우에서 도커를 설치하려면 도커 공식홈페이지에서 Docker Desktop Installer.exe 파일을 다운 받아 설치하면 된다.문제는 해당 exe 파일을 더블클릭 후 실행하면 설치경로를 변경하지 못하고 냅다 그냥 C 드라이브 설치해버린다.그리고 WSL 경로도 C:\Users\{user}\AppData\Local\Docker 로 설정한다. C드라이브 용량은 항상 부족해서, 다른 드라이브에 도커를 설치하는 방법을 찾아봤다.https://stackoverflow.com/questions/75727062/how-to-install-docker-desktop-on-a-different-drive-location-on-windows How to install Docker Desktop on a differe..
-
스프링부트 인터셉터(interceptor) 사용해보기개발관련/개인플젝 2022. 11. 3. 18:34
메인 페이지에서 로그인하면 사용자 이름을 맨 위에 표기되도록 해놓았다. @GetMapping({"", "/"}) public String userIndex(Model model, @PageableDefault Pageable pageable, @CurrentUser UserAccount userAccount) { model.addAttribute("itemDtoPage",itemService.findPageWithResponseDto(pageable)); if(userAccount != null) { model.addAttribute("userName", userAccount.getName()); } return "index"; } 컨트롤러는 위처럼 @AuthenticationPrincipal 어노테이션..
-
스프링부트 File객체를 MultipartFile로 변환하기(삽질)개발관련 2022. 10. 21. 20:07
서버를 실행시킬 때 아이템하고 이미지들을 미리 100개 정도 만들어보려고 했다.그래서 구글에서 검색해서 File객체를 MultipartFile로 변환하려고 했다.File file = new File("/path/to/file");FileItem fileItem = new DiskFileItem("mainFile", Files.probeContentType(file.toPath()), false, file.getName(), (int) file.length(), file.getParentFile());try { InputStream input = new FileInputStream(file); OutputStream os = fileItem.getOutputStream(); IOUtils...
-
스프링부트 스케쥴러(Scheduler) 사용해보기(feat. java.nio 패키지)개발관련 2022. 10. 18. 01:17
아이템 등록 시 대표이미지를 무조건 1개 등록해야 한다. 아이템 삭제나, 아이템 이미지 삭제 시 DB에서만 삭제하게 하고 실제 디스크에 있는 파일은 스케쥴러를 통해서 파일DB와 실제디스크의 파일목록과 비교해서 삭제해보려고 한다. @Slf4j @Component @EnableScheduling public class Scheduler { private final ItemFileRepository itemFileRepository; @Value("${file.upload-image-dir}") String uploadPath; public Scheduler(ItemFileRepository itemFileRepository) { this.itemFileRepository = itemFileRepository..
-
스프링부트 테스트코드에서 Mockfile 로 파일업로드 테스트 해보기개발관련 2022. 10. 17. 17:47
@DisplayName("아이템 저장 - 정상") @Test @WithUserDetails(value = "admin", setupBefore = TestExecutionEvent.TEST_EXECUTION) void itemSave() throws Exception { //카테고리 등록 Category category = saveCategory("testCategory"); Path path = Paths.get(Objects.requireNonNull(getClass().getResource("/static/images/_freeApple.jpg")).toURI()); byte[] bytes = Files.readAllBytes(path); MockMultipartFile file = new Mock..