Skip to content

Commit 4c42c5b

Browse files
committed
Merge 'feature/yg/meego-7022395131-ve-login-support' into 'master'
feat(login): support console login See merge request: !65
2 parents 9bba857 + 79f9f2f commit 4c42c5b

20 files changed

Lines changed: 3225 additions & 16 deletions

README.EN.MD

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,72 @@ After logout, run `ve sso login` to keep using the same account and role. Run `v
307307
- What should I enter for Scopes?
308308
Usually nothing. The default is `cloudidentity:account:access,offline_access`. If you enter scopes manually, only `cloudidentity:account:access` and `offline_access` are allowed; the CLI deduplicates and validates them.
309309
310+
#### Console Login (login)
311+
312+
```shell
313+
# Sign in with the default profile. If region is omitted, the CLI prompts for it
314+
ve login
315+
316+
# Recommended: specify profile and region; profile/region support -p/-r
317+
ve login -p dev -r cn-beijing
318+
319+
# Use cross-device login for headless, remote-server, or container environments
320+
ve login -p dev -r cn-beijing --remote
321+
```
322+
323+
This command signs in through the Volcengine Console using OAuth 2.0 + PKCE, caches temporary STS credentials locally, and lets later service commands reuse the temporary credentials from that profile.
324+
325+
Parameters:
326+
- `--profile, -p`: configuration profile name; defaults to `default`
327+
- `--region, -r`: region; when omitted, the CLI prompts for it and uses `cn-beijing` if you press Enter
328+
- `--remote`: cross-device login; open the URL printed by the CLI in a browser, finish login, and paste the full authorization code shown in the browser back into the terminal
329+
- `--endpoint-url`: sign-in service endpoint; defaults to `https://signin.volcengine.com` and normally does not need to be changed
330+
331+
Notes:
332+
- After login, the profile is written with `mode` set to `console-login` and a `login-session`
333+
- After logging in with a non-`default` profile, service commands do not automatically switch profiles; run `ve configure profile --profile dev` first
334+
- Use `--remote` when the browser cannot redirect back to the machine running the CLI
335+
336+
End-to-end example:
337+
338+
```shell
339+
# 1. Sign in and write the dev profile
340+
ve login --profile dev --region cn-beijing
341+
342+
# 2. If dev is not the current default profile, switch the active profile first
343+
ve configure profile --profile dev
344+
345+
# 3. Service commands use the console-login temporary credentials from the current profile
346+
ve ecs DescribeInstances
347+
348+
# 4. When finished, clear the local login state
349+
ve logout --profile dev
350+
```
351+
352+
#### Console Logout (logout)
353+
354+
```shell
355+
# Log out the default profile
356+
ve logout
357+
358+
# Log out a specific profile
359+
ve logout -p dev
360+
361+
# Log out all Console Login profiles in the current configuration
362+
ve logout --all
363+
```
364+
365+
This command clears the local login state created by `ve login`. It removes locally cached credentials and clears the profile's `login-session`; it does not delete the profile or send a logout request to the server.
366+
367+
Parameters:
368+
- `--profile, -p`: configuration profile name; defaults to `default`
369+
- `--all`: clear all `console-login` profiles in the current configuration; ignores `--profile`
370+
371+
Notes:
372+
- `ve logout` without `--profile` only handles the `default` profile; it does not automatically log out `current`
373+
- This command only applies to `console-login` profiles; AK/SSO profiles are not affected
374+
- Run `ve login` again when you need to use Console Login credentials after logout
375+
310376
#### Configure Auto-Completion
311377
312378
By executing ve completion --help, users can view the methods for configuring auto-completion in various terminals. Based on the instructions provided, users may choose whether to configure the auto-completion feature.

README.MD

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,72 @@ ve sso logout
313313
- Scopes 应该怎么填?
314314
通常可以省略,默认使用 `cloudidentity:account:access,offline_access`。如果手动填写,只允许 `cloudidentity:account:access``offline_access`,CLI 会自动去重并校验。
315315

316+
#### Console 登录 (login)
317+
318+
```shell
319+
# 使用默认 profile 登录,未指定 region 时会提示输入
320+
ve login
321+
322+
# 推荐:指定 profile 和地域,profile/region 支持 -p/-r 简写
323+
ve login -p dev -r cn-beijing
324+
325+
# 无浏览器、远程服务器或容器环境使用跨设备登录
326+
ve login -p dev -r cn-beijing --remote
327+
```
328+
329+
该命令通过火山引擎控制台完成 OAuth 2.0 + PKCE 登录,并将临时 STS 凭证缓存到本地,后续业务命令可复用该 profile 的临时凭证。
330+
331+
参数说明:
332+
- `--profile, -p`:配置名称,默认 `default`
333+
- `--region, -r`:地域;未指定时会提示输入,直接回车使用 `cn-beijing`
334+
- `--remote`:跨设备登录;按终端输出的 URL 在浏览器完成登录,并将浏览器展示的授权码完整粘贴回终端
335+
- `--endpoint-url`:登录服务地址,默认 `https://signin.volcengine.com`,通常无需修改
336+
337+
注意事项:
338+
- 登录成功后,profile 会被写为 `console-login` 模式,并记录 `login-session`
339+
- 使用非 `default` profile 登录后,业务命令不会自动切换 profile;需要先执行 `ve configure profile --profile dev`
340+
- 本机浏览器无法回跳 CLI 所在机器时,使用 `--remote`
341+
342+
完整使用流程示例:
343+
344+
```shell
345+
# 1. 登录并写入 dev profile
346+
ve login --profile dev --region cn-beijing
347+
348+
# 2. 如果 dev 不是当前默认 profile,先切换当前使用的配置
349+
ve configure profile --profile dev
350+
351+
# 3. 执行业务命令时会使用当前 profile 中的 console-login 临时凭证
352+
ve ecs DescribeInstances
353+
354+
# 4. 使用结束后清理本地登录状态
355+
ve logout --profile dev
356+
```
357+
358+
#### Console 登出 (logout)
359+
360+
```shell
361+
# 登出 default profile
362+
ve logout
363+
364+
# 登出指定 profile
365+
ve logout -p dev
366+
367+
# 登出当前配置中的所有 Console Login profile
368+
ve logout --all
369+
```
370+
371+
该命令用于清理 `ve login` 建立的本地登录状态。它只删除本地缓存凭证并清除 profile 中的 `login-session`,不会删除 profile,也不会向服务端发起请求。
372+
373+
参数说明:
374+
- `--profile, -p`:配置名称,默认 `default`
375+
- `--all`:清理当前配置中的所有 `console-login` profile;开启后忽略 `--profile`
376+
377+
注意事项:
378+
- `ve logout` 不带 `--profile` 时只处理 `default` profile,不会自动按 `current` 登出
379+
- 只有 `console-login` profile 可使用该命令;AK/SSO profile 不适用
380+
- 登出后若需继续使用,重新执行 `ve login`
381+
316382
#### 配置自动补全
317383

318384
使用 ve completion --help 可以查看各种终端下配置自动补全的方式,用户可以根据提示信息自己选择是否配置自动补全功能
@@ -449,4 +515,3 @@ For vulnerability reporting and supported versions, see [SECURITY.md](SECURITY.m
449515

450516

451517

452-

0 commit comments

Comments
 (0)