You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stomphandler의 presend에서 웹소켓 헤더의 jwt 토큰을 검증한다. 즉 헤더에 토큰값이 올바르게 입력되지 않으면 메시지 자체가 전송되지 않는 구조.
문제점
일반적으로는 http로 처음 socket connection을 맺을 때에는 header에 인증정보를 넣지만, websocket으로 데이터를 송 / 수신할 때에는 굳이 검증 로직을 넣지 않는다. 매번 websocket으로 메시지를 보낼 때마다 헤더에 jwt 문자열이 포함되기 때문에
메시지 헤더의 크기가 본문인 채팅보다 더 커진다.
채팅 횟수가 증가할 경우, 매번 헤더의 jwt 토큰을 확인하는 데 걸리는 시간. (scalable할 수 있는가?)
-> 이렇게 된 이유는 http + websocket으로 connection을 맺을 때, 연결된 사용자의 고유값 (userId) 정보를 stateful하게 내부적으로 관리하는 방법을 아직 모르기 때문.
-> 일단은 "허용되지 않은 사용자가 방에 메시지를 보내는 상황"을 최대한 막기 위해 이런 방식을 사용했지만, 추후에 http + websocket 연결 시 userId정보를 유지하는 방법을 알아내야 함.
기존에 작성된 채팅 컨트롤러
문제 1
Authentication 객체로 토큰이 받아와 지지 않는다.
@Header("Authorization")
헤더 이용문제 2
@Header("Authorization") Authentication authentication
이렇게 토큰 받아와 지지 않음@Header("Authorization") String authentication
String 으로 가져와 진다.SimpMessageHeaderAccessor authentication
로 받아와서authentication.getNativeHeader("Authorization").get(0);
으로 가져올 수 있는데 결국 이것도 String임문제 3
String으로 받아온 토큰을 Authentication 객체 혹은 JwtAuthenticationToken 객체로 만드려고 시도해봤으나 실패
그럼 되는 방법 ?
고민해봐야할 사항
The text was updated successfully, but these errors were encountered: