JWT

이소연's avatar
Aug 05, 2024
JWT
aop?
 
공개키, 개인키 =아직 때가 아니다.
 
스트키세션 : 한 곡에 고정됨. 짐 맡기면
과정을 설명해야 함.
차례차례 막하는?
제이슨 웹 토큰
맥락을 이해하삼
 
jwt를 직접 가져가야 한다고?
jsession set cookie
에 넣었다면 지금 은 jwt
 
예전에는 set 쿠키 하고 그 정보를? 브라우저가 저장해둔다고?
notion image
notion image
자동차 lcd
 
notion image
브라우저만 세션을 원하고
다른 거는 json을 원함
하나의 db의?
 
브라우저 외
다른 것들은 그런 프로토콜이 없어
radis로 하는 게 편함
 
세션의 장점
브라우저있을 때
홈태그 요청있는 걸 헤더에 넣어줌.
그럴 바에 json web tocen better??
그래서 redirect을 쓴다고??? 브라우저 > 세션 > 서버에서???
뷰는 스스로 된다고?
 
based64? 인코딩하면 문자열로 바껴서 제이슨에 함께 넣을 수 있어?
 
복호화
notion image
애를 서명해가지고 전자 서명을 하면 부인 방지가 된다고?
단방향 해시
notion image
유저 아이디,이름??
여기서 pw 하면 매우 위험
 
notion image
 
개인의 특정한 정보로 하지 x
notion image
서버입장의 키를 만듦
토큰 만들어 응답
토큰 검증 세션에서 값을 넣을 수 있다고???
 
디티오에 뭐하면 qlrm 필요x
이거 이제 좀 알아봐야 함
dependencies { //서드파티 implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.0' implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation group: 'com.auth0', name: 'java-jwt', version: '4.3.0' implementation group: 'org.qlrm', name: 'qlrm', version: '4.0.1' implementation group: 'org.mindrot', name: 'jbcrypt', version: '0.4' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-mustache' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'com.h2database:h2' runtimeOnly 'com.mysql:mysql-connector-j' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' }
 
우리 팀플 할때는 dto 같이 하지말고 각자해라
 
허거블코튼 유명
 
 
토큰>>
토큰으로 세션에 놨두는 게 better-v
 
그날 갔을 때만 살짝 쓰는 것. 세션말고 jwt는
세션기반 -키 가져감 매일매일 락카가 달라짐.
(요청할 때마다 라카 바뀜)
session은 재 사용. 할 동안
 
-짐은 왜 안가져가????
 
임시세션을 만듦??
a로 갔다가 b로 감
 
package shop.mtcoding.blog._core.interceptor; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; import shop.mtcoding.blog._core.errors.exception.Exception401; import shop.mtcoding.blog.user.User; // /api/** 인증 필요 주소 public class LoginInterceptor implements HandlerInterceptor{ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String jwt = request.getHeader("Authorization"); System.out.println("preHandle............"); //이게 토큰???????? HttpSession session = request.getSession(); User sessionUser = (User) session.getAttribute("sessionUser"); if(sessionUser == null){ throw new Exception401("로그인 하셔야 해요"); } return true; } } . ---
 
 
notion image
notion image
notion image
 
 
물어볼 때 정확히 어느 부분을 모르는 지 기술
-예를 들어 뷰 뿌리기, 보드 비지니스(흐름 느낌),등 자세하게 기술하여 물어봐요
Share article

Coding's note