Skip to content

Commit

Permalink
Merge pull request #29 from SafeNet-2024/feature/add-security
Browse files Browse the repository at this point in the history
[feat] ๋ฉ”์‹œ์ง€ ๋ณด๋‚ผ ๋•Œ resolve ํ›„ validation ์ง„ํ–‰
  • Loading branch information
khee2 authored Jun 12, 2024
2 parents 42205a9 + 5087be9 commit bc63cce
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ public void message(@RequestHeader(name = "ACCESS_TOKEN", required = false) Stri
MessageDto messageDto) {
try {
// Access Token ๊ฒ€์ฆ
if (accessToken == null || !jwtTokenProvider.validateToken(accessToken)) { // ๋ฉ”์‹œ์ง€ ์ „์†ก ์ „ ์œ ํšจํ•œ ํ† ํฐ์ธ์ง€ ๊ฒ€์ฆ
throw new AccessDeniedException("Invalid or expired token");
if (accessToken != null && accessToken.startsWith("Bearer ")) {
String token = accessToken.substring(7);
if (jwtTokenProvider.validateToken(token)) {
// ๋ฉ”์‹œ์ง€ ์ „์†ก ๋กœ์ง ํ˜ธ์ถœ
messageRoomService.handleMessage(messageDto.getRoomId(), messageDto.getSender(), messageDto);
} else {
throw new AccessDeniedException("Invalid or expired token");
}
} else {
throw new AccessDeniedException("Missing or invalid ACCESS_TOKEN header");
}
// ๋ฉ”์‹œ์ง€ ์ „์†ก ๋กœ์ง ํ˜ธ์ถœ
messageRoomService.handleMessage(messageDto.getRoomId(), messageDto.getSender(), messageDto);
} catch (Exception e) {
log.error("Failed to send message: {}", e.getMessage());
throw e;
Expand Down

0 comments on commit bc63cce

Please sign in to comment.