Codestates [Back-end]/데일리 로그 [TIL]
22.09.27 JWT - SpringSecurity 인증 (step 1. 사전 작업)
목표 : SpringSecurity기반의 앱에 JWT를 이용한 보안 강화 1. JWT 생성 및 갱신, 클라쪽에서 보낸 JWT의 유효성 검증 등 2. SpringSecurity의 Filter Chain과의 연계 Step Step 1. 사전작업 : 현재 글 Step 2. 로그인 인증 구현 ( 인증 / Authentication ) : https://radpro.tistory.com/310 Step 3. 자격증명 및 검증 구현 ( 인가 / Authorization ) : https://radpro.tistory.com/311 build.gradle dependencies { ... // SpringSecurity를 위한 라이브러리 implementation 'org.springframework.boot:spr..
22.09.26 JWT - 생성 및 검증 테스트
build.gradle * jjwt 라이브러리 0.11.5버전 기준 * jjwt설명 참고 링크 ( https://radpro.tistory.com/307 ) dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' // 여기부터 추가 -----..

22.09.26 JWT 이론
목표 : 인증에 대한 토큰과 세션의 방식차이 JWT (JSON Web Token) : 의미 / JWT의 구성요소 / 동작방식 토큰과 세션 1. 토큰과 세션의 필요성 : HTTP 프로토콜의 특성 비연결성(Connectionless) : HTTP프로토콜은 request 후 response가 끝나면 연결이 끊김 비상태성(Stateless) : HTTP프로토콜은 request와 resuponse에 대한 상태를 저장하지 않음 비상태성 + 비연결성 = 요청마다 매번 인증받아야하는 번거로움이 있음 2. 토큰 기반 : 인증된 사용자 정보를 서버에서 별도로 관리 X (토큰에 서명이 있을뿐) = 서버 부담 적고 확장성 좋음. 세션 불일치 문제 없음 : 생성된 토큰을 헤더에 포함시켜 request => 인증된 사용자인지 증..
22.09.23 SpringSecutiry - DelegatingPasswordEncoder
DelegatingPasswordEncoder란? : PasswordEncoder 구현 객체를 생성해주는 컴포넌트 : 앱에서 사용할 PasswordEncoder를 결정 => 결정된 PasswordEncoder로 사용자가 입력한 패스워드를 단방향 암호화 DelegatingPasswordEncoder 장점 1. 다양한 방식의 알고리즘 적용가능 ( 여러 방식 마이그레이션 용이 ) 2. 디폴트 값은 SpringSecurity에서 권장하는 최신 암호화 알고리즘으로 적용 3. Password 검증은 레거시 방식의 암호화 알고리즘으로, 암호화된 패스워드의 검증 지원 4. 암호화 방식을 변경하고 싶다면, 언제든 변경가능. 단, 기존에 암호화 되어 저장된 password에 대한 마이그레이션 작업 필요 * Delegati..