Skip to content
Snippets Groups Projects
Commit 45b5c4db authored by Tom Käsler's avatar Tom Käsler
Browse files

Add tracing messages to ws auth handling for better debugging

parent 884f6446
Branches
1 merge request!139Add tracing on incoming messages
Pipeline #29387 passed with warnings with stages
in 1 minute and 26 seconds
...@@ -31,13 +31,16 @@ public class AuthChannelInterceptorAdapter implements ChannelInterceptor { ...@@ -31,13 +31,16 @@ public class AuthChannelInterceptorAdapter implements ChannelInterceptor {
@Nullable @Nullable
@Override @Override
public Message<?> preSend(final Message<?> message, final MessageChannel channel) { public Message<?> preSend(final Message<?> message, final MessageChannel channel) {
logger.trace("Inspecting incoming message: {}", message);
final StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); final StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
final String sessionId = accessor.getSessionId(); final String sessionId = accessor.getSessionId();
if (accessor.getCommand() != null && accessor.getCommand().equals(StompCommand.CONNECT)) { if (accessor.getCommand() != null && accessor.getCommand().equals(StompCommand.CONNECT)) {
// user needs to authorize // user needs to authorize
logger.trace("Incoming message is a connect command");
final List<String> tokenList = accessor.getNativeHeader("token"); final List<String> tokenList = accessor.getNativeHeader("token");
if (tokenList != null && tokenList.size() > 0) { if (tokenList != null && tokenList.size() > 0) {
logger.trace("Adding token {} to the ws session mapping", tokenList.get(0));
final String token = tokenList.get(0); final String token = tokenList.get(0);
service.addWsSessionToJwtMapping(sessionId, token); service.addWsSessionToJwtMapping(sessionId, token);
} else { } else {
...@@ -46,9 +49,11 @@ public class AuthChannelInterceptorAdapter implements ChannelInterceptor { ...@@ -46,9 +49,11 @@ public class AuthChannelInterceptorAdapter implements ChannelInterceptor {
return null; return null;
} }
} else { } else {
logger.trace("Incoming message is anything but a connect command");
final List<String> userIdList = accessor.getNativeHeader("ars-user-id"); final List<String> userIdList = accessor.getNativeHeader("ars-user-id");
if (userIdList != null && userIdList.size() > 0) { if (userIdList != null && userIdList.size() > 0) {
// user-id is given, check for auth // user-id is given, check for auth
logger.trace("Checking user id with ws session mapping");
final String userId = userIdList.get(0); final String userId = userIdList.get(0);
final User u = service.getAuthenticatedUserByWsSession(sessionId); final User u = service.getAuthenticatedUserByWsSession(sessionId);
if (u == null || !userId.equals(u.getId())) { if (u == null || !userId.equals(u.getId())) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment