Skip to content

Commit 2f9558c

Browse files
committed
refactor(auth): remove deprecated AK/SK auth for knowledge retrieve
AK/SK signing was used only by `knowledge retrieve`'s deprecated fallback, which the api-key auth gate now makes unreachable. Drop it; the command is pure api-key. - knowledge/retrieve: remove the AK/SK path + --access-key-id/secret/workspace-id flags; api-key only - delete client/ak-sign.ts and its signRequest/AkSignConfig exports - drop access_key_id/access_key_secret from config schema, loader, and `config show` / `config set` - remove the now-unused PascalCase KnowledgeRetrieve request/response types
1 parent 95eb07d commit 2f9558c

19 files changed

Lines changed: 63 additions & 476 deletions

File tree

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,6 @@ Required for console capability commands (`app list`, `usage free`, `usage stats
156156
bl auth login --console
157157
```
158158

159-
### Alibaba Cloud AK/SK (Knowledge Base only)
160-
161-
Required for `knowledge retrieve`. Get your AccessKey from [RAM Console](https://ram.console.aliyun.com/manage/ak).
162-
163-
> Recommended: create a RAM sub-account with minimum privileges instead of using the root account's AK/SK.
164-
165-
```bash
166-
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
167-
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
168-
export BAILIAN_WORKSPACE_ID=ws-...
169-
```
170-
171159
## Configuration
172160

173161
```bash

README.zh.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,6 @@ bl text chat --api-key sk-xxxxx --message "你好"
151151
bl auth login --console
152152
```
153153

154-
### 阿里云 AK/SK(仅知识库检索)
155-
156-
`knowledge retrieve` 命令需要阿里云 AccessKey。前往 [RAM 控制台](https://ram.console.aliyun.com/manage/ak) 获取。
157-
158-
> 建议:创建 RAM 子账号并授予最小权限,避免使用主账号 AK/SK。
159-
160-
```bash
161-
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
162-
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
163-
export BAILIAN_WORKSPACE_ID=ws-...
164-
```
165-
166154
## 配置
167155

168156
```bash

packages/cli/README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,6 @@ Required for console capability commands (`app list`, `usage free`, `usage stats
156156
bl auth login --console
157157
```
158158

159-
### Alibaba Cloud AK/SK (Knowledge Base only)
160-
161-
Required for `knowledge retrieve`. Get your AccessKey from [RAM Console](https://ram.console.aliyun.com/manage/ak).
162-
163-
> Recommended: create a RAM sub-account with minimum privileges instead of using the root account's AK/SK.
164-
165-
```bash
166-
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
167-
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
168-
export BAILIAN_WORKSPACE_ID=ws-...
169-
```
170-
171159
## Configuration
172160

173161
```bash

packages/cli/README.zh.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,6 @@ bl text chat --api-key sk-xxxxx --message "你好"
151151
bl auth login --console
152152
```
153153

154-
### 阿里云 AK/SK(仅知识库检索)
155-
156-
`knowledge retrieve` 命令需要阿里云 AccessKey。前往 [RAM 控制台](https://ram.console.aliyun.com/manage/ak) 获取。
157-
158-
> 建议:创建 RAM 子账号并授予最小权限,避免使用主账号 AK/SK。
159-
160-
```bash
161-
export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
162-
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
163-
export BAILIAN_WORKSPACE_ID=ws-...
164-
```
165-
166154
## 配置
167155

168156
```bash

packages/cli/tests/e2e/global-setup.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ DASHSCOPE_API_KEY=
3030
# -------------------------------
3131
BAILIAN_E2E_VIDEO_TASK_ID=b499a8cb-1fc4-4d43-9495-e23c7f78ae0d
3232
# -------------------------------
33-
# 阿里云 AK
34-
ALIBABA_CLOUD_ACCESS_KEY_ID=
35-
# 阿里云 SK
36-
ALIBABA_CLOUD_ACCESS_KEY_SECRET=
37-
# -------------------------------
3833
# 知识库 ID
3934
BAILIAN_WORKSPACE_ID=
4035
# 索引 ID

packages/cli/tests/e2e/helpers.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,11 @@ export function e2eLabelFromMetaUrl(metaUrl: string): string {
117117
return basename(fileURLToPath(metaUrl), ".ts").replace(/\.e2e\.test$/, "");
118118
}
119119

120-
/** 知识库用例:须显式索引 ID + API-KEY 或 AK/SK */
120+
/** 知识库用例:须显式索引 ID + API-KEY */
121121
export function isKnowledgeE2EReady(): boolean {
122122
if (!isBailianE2EEnabled()) return false;
123123
if (!process.env.BAILIAN_E2E_INDEX_ID) return false;
124-
const hasApiKey = isDashScopeE2EReady();
125-
const hasAkSk =
126-
!!process.env.ALIBABA_CLOUD_ACCESS_KEY_ID && !!process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET;
127-
return hasApiKey || hasAkSk;
128-
}
129-
130-
export function isKnowledgeAkSkReady(): boolean {
131-
return (
132-
isBailianE2EEnabled() &&
133-
!!process.env.ALIBABA_CLOUD_ACCESS_KEY_ID &&
134-
!!process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET &&
135-
!!process.env.BAILIAN_E2E_INDEX_ID
136-
);
124+
return isDashScopeE2EReady();
137125
}
138126

139127
export interface RunCliResult {

packages/cli/tests/e2e/knowledge.e2e.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ describe("e2e: knowledge retrieve", () => {
3535
expect(stderr).toMatch(/--query/i);
3636
expect(stderr).toMatch(/--rerank-top-n/i);
3737
expect(stderr).toMatch(/deprecated/i);
38-
expect(stderr).toMatch(/--workspace-id/i);
3938
});
4039

4140
test("缺少 --index-id 时打印帮助并退出 (0)", async () => {
@@ -82,8 +81,6 @@ describe("e2e: knowledge retrieve errors", () => {
8281
{
8382
DASHSCOPE_API_KEY: undefined,
8483
DASHSCOPE_ACCESS_TOKEN: undefined,
85-
ALIBABA_CLOUD_ACCESS_KEY_ID: undefined,
86-
ALIBABA_CLOUD_ACCESS_KEY_SECRET: undefined,
8784
BAILIAN_CONFIG_DIR: tmpdir(),
8885
},
8986
);

packages/commands/src/commands/config/set.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ const VALID_KEYS = [
2121
"default_image_model",
2222
"default_speech_model",
2323
"default_omni_model",
24-
"access_key_id",
25-
"access_key_secret",
2624
"workspace_id",
2725
];
2826

2927
// Keys whose values are secrets. Their stored value must never be echoed back in
3028
// cleartext (CI logs, pipes, shared terminals); show a masked form instead — the
3129
// same policy `config show` and `auth status` already follow.
32-
const SECRET_KEYS = new Set(["api_key", "access_token", "access_key_id", "access_key_secret"]);
30+
const SECRET_KEYS = new Set(["api_key", "access_token"]);
3331

3432
// Allow hyphen-style keys (e.g. default-text-model → default_text_model)
3533
const KEY_ALIASES: Record<string, string> = {
@@ -42,8 +40,6 @@ const KEY_ALIASES: Record<string, string> = {
4240
"default-image-model": "default_image_model",
4341
"default-speech-model": "default_speech_model",
4442
"default-omni-model": "default_omni_model",
45-
"access-key-id": "access_key_id",
46-
"access-key-secret": "access_key_secret",
4743
"workspace-id": "workspace_id",
4844
};
4945

@@ -56,7 +52,7 @@ export default defineCommand({
5652
type: "string",
5753
valueHint: "<key>",
5854
description:
59-
"Config key (base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)",
55+
"Config key (base_url, output, output_dir, timeout, api_key, access_token, default_*_model, workspace_id)",
6056
required: true,
6157
},
6258
value: { type: "string", valueHint: "<value>", description: "Value to set", required: true },

packages/commands/src/commands/config/show.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ export default defineCommand({
2727
if (typeof result.api_key === "string") result.api_key = maskToken(result.api_key);
2828
if (typeof result.access_token === "string")
2929
result.access_token = maskToken(result.access_token);
30-
if (typeof result.access_key_id === "string")
31-
result.access_key_id = maskToken(result.access_key_id);
32-
if (typeof result.access_key_secret === "string") {
33-
result.access_key_secret = maskToken(result.access_key_secret);
34-
}
3530

3631
emitResult(result, format);
3732
},

0 commit comments

Comments
 (0)