Skip to content

Commit

Permalink
Merge pull request #31 from SafeNet-2024/feature/add-security
Browse files Browse the repository at this point in the history
[feat] ๋ฐœํ–‰, ๊ตฌ๋…์‹œ ํ† ํฐ ๊ฒ€์ฆ ์ถ”๊ฐ€
  • Loading branch information
khee2 authored Jun 12, 2024
2 parents 8fd4c6a + 3d65b5e commit e8c0140
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ public AuthChannelInterceptor(JwtTokenProvider jwtTokenProvider) {
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
if (StompCommand.CONNECT.equals(accessor.getCommand())) {

if (StompCommand.CONNECT.equals(accessor.getCommand()) ||
StompCommand.SUBSCRIBE.equals(accessor.getCommand()) ||
StompCommand.SEND.equals(accessor.getCommand())) {

String token = accessor.getFirstNativeHeader("ACCESS_TOKEN");
log.debug("Received ACCESS_TOKEN in Interceptor: {}", token);

try {
if (token != null && token.startsWith("Bearer ")) {
token = token.substring(7);
Expand All @@ -48,6 +54,7 @@ public Message<?> preSend(Message<?> message, MessageChannel channel) {
throw e;
}
}

return message;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws-stomp").setAllowedOriginPatterns("*") // stomp websocket ์—ฐ๊ฒฐ
.withSockJS();
}
}
}

// WebSocket ๋ฉ”์‹œ์ง€์˜ ํ—ค๋”์—์„œ ACCESS_TOKEN์„ ์ถ”์ถœํ•˜๊ณ  ๊ฒ€์ฆ
// ์œ ํšจํ•œ ํ† ํฐ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์„ค์ •ํ•˜๊ณ , ์œ ํšจํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ์—ฐ๊ฒฐ์„ ์ฐจ๋‹จ

0 comments on commit e8c0140

Please sign in to comment.