Skip to content

Commit

Permalink
feat: 支持websocket #2494
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxuwan committed Nov 15, 2024
1 parent ae04b5b commit f5356e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package com.tencent.bkrepo.websocket.config
import com.tencent.bkrepo.common.security.http.jwt.JwtAuthProperties
import com.tencent.bkrepo.common.security.manager.AuthenticationManager
import com.tencent.bkrepo.websocket.constant.APP_ENDPOINT
import com.tencent.bkrepo.websocket.constant.DESKTOP_ENDPOINT
import com.tencent.bkrepo.websocket.constant.USER_ENDPOINT
import com.tencent.bkrepo.websocket.dispatch.push.TransferPush
import com.tencent.bkrepo.websocket.handler.SessionWebSocketHandlerDecoratorFactory
Expand Down Expand Up @@ -68,9 +69,9 @@ class WebsocketConfiguration(
}

override fun registerStompEndpoints(registry: StompEndpointRegistry) {
registry.addEndpoint(USER_ENDPOINT, APP_ENDPOINT)
registry.addEndpoint(USER_ENDPOINT, APP_ENDPOINT, DESKTOP_ENDPOINT)
.setAllowedOriginPatterns("*")
registry.addEndpoint(USER_ENDPOINT, APP_ENDPOINT)
registry.addEndpoint(USER_ENDPOINT, APP_ENDPOINT, DESKTOP_ENDPOINT)
.setAllowedOriginPatterns("*")
.withSockJS()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ package com.tencent.bkrepo.websocket.constant

const val USER_ENDPOINT = "/ws/user"
const val APP_ENDPOINT = "/ws/app"
const val DESKTOP_ENDPOINT = "/ws/desktop"

const val SESSION_ID = "sessionId"
6 changes: 6 additions & 0 deletions src/gateway/auth.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
internal;
content_by_lua_file 'conf/lua/auth/auth_web.lua';
}

# websocket验证身份
location = /auth/websocket {
internal;
content_by_lua_file 'conf/lua/auth/auth_websocket.lua';
}
6 changes: 3 additions & 3 deletions src/gateway/vhosts/bkrepo.websocket.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
location ~ /websocket/(ws/user.*) {
location ~ /websocket/(ws/user/.*|ws/desktop/.*) {
header_filter_by_lua_file 'conf/lua/cors_filter.lua';
auth_request /auth/web;
auth_request /auth/websocket;
# 设置auth的变量
auth_request_set $uid $sent_http_x_bkrepo_uid;
auth_request_set $accessToken $sent_http_x_bkrepo_access_token;
Expand Down Expand Up @@ -43,4 +43,4 @@ location ~ /websocket/(ws/app.*) {
proxy_set_header Connection "Upgrade";
proxy_http_version 1.1;
proxy_pass http://$target/$path?$args;
}
}

0 comments on commit f5356e2

Please sign in to comment.