|
@ -4,6 +4,8 @@ import java.util.List; |
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.context.annotation.Configuration; |
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
|
import org.springframework.core.Ordered; |
|
|
|
|
|
import org.springframework.core.annotation.Order; |
|
|
import org.springframework.messaging.Message; |
|
|
import org.springframework.messaging.Message; |
|
|
import org.springframework.messaging.MessageChannel; |
|
|
import org.springframework.messaging.MessageChannel; |
|
|
import org.springframework.messaging.simp.config.ChannelRegistration; |
|
|
import org.springframework.messaging.simp.config.ChannelRegistration; |
|
@ -25,6 +27,7 @@ import org.springframework.web.socket.config.annotation.WebSocketTransportRegist |
|
|
* Created by dima on 8/12/16. |
|
|
* Created by dima on 8/12/16. |
|
|
*/ |
|
|
*/ |
|
|
@Configuration |
|
|
@Configuration |
|
|
|
|
|
@Order(Ordered.HIGHEST_PRECEDENCE + 99) |
|
|
@EnableWebSocketMessageBroker |
|
|
@EnableWebSocketMessageBroker |
|
|
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { |
|
|
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { |
|
|
|
|
|
|
|
@ -40,6 +43,10 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { |
|
|
MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); |
|
|
MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); |
|
|
if (StompCommand.CONNECT.equals(accessor.getCommand())) { |
|
|
if (StompCommand.CONNECT.equals(accessor.getCommand())) { |
|
|
List<String> authorization = accessor.getNativeHeader("X-Authorization"); |
|
|
List<String> authorization = accessor.getNativeHeader("X-Authorization"); |
|
|
|
|
|
|
|
|
|
|
|
if (authorization == null || authorization.isEmpty()) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
String accessToken = authorization.get(0); |
|
|
String accessToken = authorization.get(0); |
|
|
Jwt jwt = jwtDecoder.decode(accessToken); |
|
|
Jwt jwt = jwtDecoder.decode(accessToken); |
|
|