분류 전체보기
-
토큰 인증과 권한체크를 Spring Cloud Gateway로 분리하기Project 2024. 9. 7. 17:09
현재 시스템은 DeliveryApp에 Spring security 의존성을 추가하여 구현한 필터 두개를 필터체인에 등록해놨다. 각 필터들의 역할은 다음과 같다. JwtAutehnticationFilter- UsernamePasswordAuthenticationFilter 구현체, 로그인 기능 담당JwtAuthorizationFilter- HttpServletRequest의 Authorization 헤더에서 accessToken을 읽어 토큰 검증 및 claims에 넣은 email을 추출- 추출한 email로 DB에서 유저정보를 가져와 Servlet에서 쓸 수 있도록 SpringContextHolder에 저장 로그인, 회원가입의 엔드포인트인 /auth로 시작하는 URL들은 Auth 정보가 없기 때문에 Jw..
-
MSA환경에서 캐시 역직렬화 문제 해결하기 | Jackson2JsonRedisSerializer 직렬화 방식 사용하기Project 2024. 9. 7. 13:42
1. 이전의 직렬화 방식 기존 모놀리식의 시스템을 MSA로 전환하면서 역직렬화 문제가 발생하게 되었다. 이전에 설정했던 캐시 직렬화 방식은 디폴트 값인 JdkSerializationRedisSerializer였다. 객체를 바이트 스트림으로 변환할때 자바 객체 데이터와 해당 클래스와 관련된 메타데이터들까지 한번에 저장하기 때문에 패키지 구조가 변경되거나(분리된 환경이거나) 클래스 안의 타입들이 자주 변경된다면 지양해야한다. 메타데이터들도 함께 저장되기 때문에 용량이 크다는 것 또한 염두해 둬야한다. 현재 유저의 unique인 email을 키로 권한정보가 들어있는 객체를 밸류로 캐싱하고 있었는데, MSA 적용으로 기존의 시스템에서 유저가 분리되게 되었다. 따라서 분리된 유저 서버에서 해당 캐시를 읽어..
-
팀 프로젝트 시작하기 | 01. 프로젝트 문서 작성하기Project 2024. 9. 6. 11:36
팀 프로젝트로 MSA구조의 물류관리서비스 개발을 진행하려고 한다.B2B 물류 관리 및 배송시스템으로 허브가 업체간의 상품 배송을 담당하는 서비스를 15일간 구현할 것이다. * ERD 명세서 * API 명세서 https://teamsparta.notion.site/d049b8201cc0494484c84da6796c1f89?v=eae2c534b7c446708827f9b90bbb0e11 API 명세서 | NotionBuilt with Notion, the all-in-one connected workspace with publishing capabilities.teamsparta.notion.site * 테이블 명세서https://teamsparta.notion.site/47ecb25b1bf8453b99b..
-
프로젝트 실행 시 환경변수 안전하게 주입하기 | AWS Secrets Manager로 환경변수 관리하기Project 2024. 8. 2. 22:49
프로젝트 진행 시 발생하는 보안 문제 중 가장 흔한 것은 설정파일에서의 민감정보 노출일 것이다. spring boot 프로젝트에선 application.yml 등의 설정파일에 데이터베이스 설정 정보 및 API 키 등을 작성해 놓는데, 이번 포스팅에서는 배포환경에서 어떻게 안전하게 민감정보들을 저장할 수 있는지 알아보자. 먼저 소스코드를 Github에 퍼블릭하게 올려놓을 때 업로드 전 properties파일에 민감정보가 없는지 꼭 확인하고 업로드 해야한다.뒤늦게 확인하고 수정하더라도 이미 히스토리로 확인이 가능하기 때문에 보안 취약점이 노출될 수 있다. 로컬에서 작업시 프로젝트 IDE에서는 시스템 환경변수를 다음과 같이 설정했었다. Run - Edit Configuration의 Build an..
-
java 프로그래머스 2018 카카오 블라인드 1차 셔틀버스 풀이 | Map, Queue 활용PS 2024. 5. 31. 14:52
https://school.programmers.co.kr/learn/courses/30/lessons/17678 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr # 문제 풀이 전 생각했던 것들1. 매개변수로 주어지는 시간들이 문자열로 주어지기 때문에 :을 기준으로 split하고 모두 분(minute)으로 변환하는 메소드가 필요하다고 생각했다. 그리고 반환형이 다시 시간형이기 때문에 분으로 환산한 시간을 00:00 형식으로 변환하는 메소드도 만들어줘야겠다고 생각했다. 2. 셔틀의 최대 개수가 10개고, 셔틀 별 정원의 수가 45명이니 사이즈가 작다고 생각했다..
-
Github Actions에서 발생하는 detached HEAD 문제 해결하기Project 2023. 12. 9. 19:37
현재상황 현 프로젝트에서 develop 브랜치에 머지하기 위해서는 반드시 PR을 통해 머지해야한다. 따라서 Github Actions의 Java CI with Gradle 작업을 활용하여 CI를 다음과 같이 자동화시켰다. name: Java CI with Gradle on: push: branches: [ "develop" ] pull_request: branches: [ "develop" ] permissions: contents: read jobs: build: runs-on: ubuntu-latest permissions: write-all steps: - name: Checkout repository uses: actions/checkout@v3 with: fetch-depth: 0 - name:..
-
[배포자동화구축] 2-2. Github Repository와 배포서버, 운영서버를 연동하기Project 2023. 11. 15. 10:18
이전시간에는 배포서버에 젠킨스를 설치하여 기본설정을 완료했다. 우린 배포서버와 운영서버가 분리되어있는 구성이기 때문에 깃헙레포 배포서버와 배포서버 운영서버 간의 연동이 필요하다. 따라서 이번에는 각 서버들을 연동하고 젠킨스에 빌드를 자동으로 실행해줄 pipeline을 구성해볼 것이다. 1. Github 레포에서 배포서버 연동하기 1-1 github Repository 설정에서 Webhooks 추가하기 레파지토리 설정에 있는 Webhooks 메뉴로 들어가 신규 webhook을 추가한다. Webhooks는 특정 이벤트가 발생할 경우 지정한 url로 레파지토리의 정보, 브랜치 정보 등을 POST로 보내는 역할을 담당한다. 우리는 push 이벤트가 발생 할 경우 jenkins 서버로 요청을 보내도록 설정할 것이..
-
[배포자동화구축] 2-1. AWS EC2에 jenkins 설치하여 배포서버 구축하기Project 2023. 10. 14. 02:57
현재 진행하고 있는 배포전략은 위와 같다. 이전 게시글에서 Github Actions를 구축했고 github이 보내는 webhook요청으로 jar파일을 만들고 운영서버로 전송하는 배포서버를 구축해야 한다. 이번 단계에서는 AWS EC2에 인스턴스를 생성하여 jenkins를 설치하고 설정하는 과정까지만 수행하고, 다음 단계에서 jenkins pipeline 구축을 진행할 것이다. 진행하며 OS나 버전이 맞지 않으면 자잘한 오류가 발생할 수 있으므로 처음부터 아래 내용과 동일하게 설정하는 것을 권장드린다. (아니면 나중에 가서 인스턴스를 삭제하고 또다시 만들어야 할 수도 있다..) 1. AWS EC2에 배포서버 생성하기 1-1 리전을 서울로 맞추고 '인스턴스 시작'으로 인스턴스 생성하기 1-2 인스턴스 이름..