feat: optional token echo in sse endpoint
This commit is contained in:
@@ -151,6 +151,7 @@ knowledge_ocean/
|
|||||||
- **TAO_SEARCH_MAX_FILES**:检索文件上限(默认 2000)
|
- **TAO_SEARCH_MAX_FILES**:检索文件上限(默认 2000)
|
||||||
- **TAO_ALLOWED_REPOS**:inspect_and_propose 允许的仓库白名单(逗号分隔)
|
- **TAO_ALLOWED_REPOS**:inspect_and_propose 允许的仓库白名单(逗号分隔)
|
||||||
- **TAO_ALLOW_GIT_PULL**:是否允许 inspect_and_propose 执行 git pull(默认 false)
|
- **TAO_ALLOW_GIT_PULL**:是否允许 inspect_and_propose 执行 git pull(默认 false)
|
||||||
|
- **TAO_ENDPOINT_TOKEN_ECHO**:若为 true,SSE endpoint 事件会回显 token(用于不带 Header 的客户端;默认 false)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
11
main.go
11
main.go
@@ -323,11 +323,16 @@ func (s *TaoServer) SSEHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
client = generateClientID()
|
client = generateClientID()
|
||||||
}
|
}
|
||||||
|
|
||||||
if queryToken != "" {
|
endpointToken := queryToken
|
||||||
|
if endpointToken == "" && getEnvBool("TAO_ENDPOINT_TOKEN_ECHO", false) {
|
||||||
|
endpointToken = token
|
||||||
|
}
|
||||||
|
|
||||||
|
if endpointToken != "" {
|
||||||
if strings.Contains(endpoint, "?") {
|
if strings.Contains(endpoint, "?") {
|
||||||
endpoint = endpoint + "&token=" + queryToken
|
endpoint = endpoint + "&token=" + endpointToken
|
||||||
} else {
|
} else {
|
||||||
endpoint = endpoint + "?token=" + queryToken
|
endpoint = endpoint + "?token=" + endpointToken
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if client != "" {
|
if client != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user