Refactor WebSocket authentication handling by removing auth requirements from the hello message. Update related documentation and schemas to reflect the changes in authentication strategy, simplifying the connection process.

This commit is contained in:
Xin Wang
2026-02-28 17:33:40 +08:00
parent 0821d73e7c
commit b4fa664d73
7 changed files with 7 additions and 67 deletions

View File

@@ -46,16 +46,12 @@ Server <- session.stopped
#### 1. Handshake: `hello`
客户端连接后发送的第一个消息,用于协议版本协商和认证
客户端连接后发送的第一个消息,用于协议版本协商。
```json
{
"type": "hello",
"version": "v1",
"auth": {
"apiKey": "optional-api-key",
"jwt": "optional-jwt"
}
"version": "v1"
}
```
@@ -63,11 +59,6 @@ Server <- session.stopped
|---|---|---|---|
| `type` | string | 是 | 固定为 `"hello"` |
| `version` | string | 是 | 协议版本,固定为 `"v1"` |
| `auth` | object | 否 | 认证信息 |
**认证规则**
- 若配置了 `WS_API_KEY`,必须提供匹配的 `apiKey`
-`WS_REQUIRE_AUTH=true`,至少需要提供 `apiKey``jwt` 之一
---
@@ -291,8 +282,6 @@ Server <- session.stopped
| `protocol.invalid_message` | 消息格式错误 |
| `protocol.order` | 消息顺序错误 |
| `protocol.version_unsupported` | 协议版本不支持 |
| `auth.invalid_api_key` | API Key 无效 |
| `auth.required` | 需要认证 |
| `audio.invalid_pcm` | PCM 数据无效 |
| `audio.frame_size_mismatch` | 音频帧大小不匹配 |
| `server.internal` | 服务端内部错误 |