aboutsummaryrefslogtreecommitdiff
path: root/juick-server-web/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-01-30 17:39:37 +0300
committerGravatar Vitaly Takmazov2018-01-30 17:39:37 +0300
commitc6f081c30b378b9b0c3210bddb653c87059e75c8 (patch)
tree4736b0c20087a82cac8d94b79e0712e0cd831eaf /juick-server-web/src/main
parentbb17bb3d03c94bd561d1bfc5b011b49340c2fbfa (diff)
web: authenticate websocket client
Diffstat (limited to 'juick-server-web/src/main')
-rw-r--r--juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java b/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java
index 7ddda36e..5b0cf178 100644
--- a/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java
+++ b/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java
@@ -1,25 +1,34 @@
package com.juick.server.configuration;
import com.juick.server.component.JuickServerComponent;
+import com.juick.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.socket.client.WebSocketConnectionManager;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
+import org.springframework.web.util.UriComponentsBuilder;
import javax.inject.Inject;
@Configuration
@EnableScheduling
public class JuickServerComponentConfiguration {
- @Value("${websocket_url:ws://localhost:8080/ws/}")
- private String WS_URI;
+ @Value("${websocket_url:ws://localhost:8080/}")
+ private String baseUri;
+ @Value("${service_user:juick}")
+ private String serviceUser;
+ @Inject
+ private UserService userService;
@Inject
private JuickServerComponent juickServerComponent;
@Bean
public WebSocketConnectionManager connectionManager() {
- WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), juickServerComponent, WS_URI);
+ String hash = userService.getHashByUID(userService.getUIDbyName(serviceUser));
+ String websocketURI = UriComponentsBuilder.fromUriString(baseUri)
+ .queryParam("hash", hash).build().toUriString();
+ WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), juickServerComponent, websocketURI);
manager.setAutoStartup(true);
return manager;
}