Skip to content

Commit 1370030

Browse files
committed
Merge 'feature/yg/meego-6788502318-sso-support-prod' into 'master'
chore(cli sso): optimize code See merge request: !59
2 parents 5dc27e7 + 85ae707 commit 1370030

13 files changed

Lines changed: 3501 additions & 62 deletions

README.EN.MD

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,86 @@ When deleting a configuration, the profile field must be specified to indicate t
157157
158158
If the configuration to be deleted is currently in use, then after successful deletion, Volcano Engine CLI will attempt to randomly select one of the remaining configurations as the new current configuration.
159159
160+
#### SSO Session Management
161+
162+
###### Configure SSO Session (configure sso-session)
163+
164+
```shell
165+
ve configure sso-session --name [session name] --start-url [SSO Start URL] --region [region] --registration-scopes [scope1,scope2]
166+
```
167+
168+
This command creates or updates an SSO session for later use with `configure sso`. Behaviors and parameters:
169+
170+
```shell
171+
name: SSO session name; if omitted, enter interactive selection/creation mode
172+
start-url: SSO Start URL; required; if editing an existing session, Enter keeps the default
173+
region: SSO region; required; default is cn-beijing, existing session values are used as defaults
174+
registration-scopes: SSO scope list (comma-separated); allowed values are cloudidentity:account:access, offline_access
175+
```
176+
177+
Interactive flow notes:
178+
- If no sessions exist, you will be prompted to enter a non-empty session name
179+
- If sessions exist, you get a searchable list with “<Create new session>” to add one
180+
- When editing, Start URL, Region, and Scopes are pre-filled; press Enter to keep defaults
181+
- Scopes are deduplicated and validated; empty input falls back to cloudidentity:account:access, offline_access
182+
183+
###### Configure SSO Profile (configure sso)
184+
185+
```shell
186+
ve configure sso --profile [profile name] --sso-session [session name] --no-browser
187+
```
188+
189+
This command configures an SSO profile, links an SSO session, runs the device authorization flow, and writes the profile to ~/.volcengine/config.json. Behaviors and parameters:
190+
191+
```shell
192+
profile: profile name; empty uses {sso-role-name}-{sso-account-id} as the default
193+
sso-session: SSO session name; if omitted, enter interactive selection/creation mode
194+
no-browser: do not automatically open the browser; default false
195+
```
196+
197+
Notes:
198+
- If the profile already exists and is not an SSO profile, the command will refuse to overwrite it
199+
- If the SSO session does not exist, you will be guided to create it and enter Start URL, Region, and Scopes
200+
201+
202+
#### SSO Login and Logout
203+
204+
##### SSO Login (sso login)
205+
206+
```shell
207+
ve sso login --profile [profile name]
208+
# or
209+
ve sso login --sso-session [session name]
210+
```
211+
212+
This command logs in via SSO, obtains an access token, and caches it. Parameters:
213+
214+
```shell
215+
profile: the SSO profile to use; must exist, be of sso type, and have sso-session configured
216+
sso-session: the SSO session to use; the session must exist and be valid
217+
no-browser: do not automatically open the browser; default false
218+
```
219+
220+
Login behavior:
221+
- If neither profile nor sso-session is provided: error when no sessions are configured; use the only session if one exists; otherwise enter interactive selection with search
222+
- Only the device code flow is supported; use `--no-browser` to disable auto-opening the browser
223+
224+
##### SSO Logout (sso logout)
225+
226+
```shell
227+
ve sso logout --sso-session [session name]
228+
```
229+
230+
This command logs out from SSO by revoking the cached token and clearing local credentials. Parameters:
231+
232+
```shell
233+
sso-session: the SSO session name to log out
234+
```
235+
236+
Logout behavior:
237+
- If sso-session is not provided: error when no sessions are configured; logout the only session if one exists; otherwise enter interactive selection that includes “All SSO sessions”
238+
- Batch logout logs out each session and returns aggregated errors on failure
239+
160240
#### Configure Auto-Completion
161241
162242
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.
@@ -271,3 +351,4 @@ The following code examples are provided:
271351
```shell
272352
ve rds_mysql ModifyDBInstanceIPList --body '{"InstanceId":"xxxxxx", "GroupName": "xxxxxx", "IPList": ["10.20.30.40", "50.60.70.80"]}'
273353
```
354+

README.MD

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,85 @@ ve configure delete --profile [配置名]
163163

164164
若待删除的是当前正在使用的配置,则删除成功后 火山引擎CLI 会尝试从剩余的配置中随机挑选一个作为当前配置
165165

166+
#### SSO Session 管理
166167

168+
###### 配置 SSO 会话 (configure sso-session)
169+
170+
```shell
171+
ve configure sso-session --name [会话名] --start-url [SSO Start URL] --region [地区] --registration-scopes [scope1,scope2]
172+
```
173+
174+
该命令用于新增或修改 SSO 会话,后续可被 `configure sso` 复用。支持的行为与参数说明:
175+
176+
```shell
177+
name: SSO 会话名称;未提供时进入交互式选择/创建模式
178+
start-url: SSO Start URL;必填,若已有会话则支持回车使用默认值
179+
region: SSO 区域;必填,默认 cn-beijing,已有会话会回填默认值
180+
registration-scopes: SSO scope 列表(逗号分隔);允许值仅 cloudidentity:account:access, offline_access
181+
```
182+
183+
交互式流程说明:
184+
- 若当前无任何 SSO 会话,会提示输入会话名,不能为空
185+
- 若已有会话,会进入可搜索的列表选择,可选 “<Create new session>” 创建新会话
186+
- 编辑已有会话时,Start URL、Region、Scopes 会回填默认值,回车可沿用
187+
- Scopes 会进行去重与校验;未输入时使用默认值 cloudidentity:account:access, offline_access
188+
189+
###### 配置 SSO 类型 profile (configure sso)
190+
191+
```shell
192+
ve configure sso --profile [配置名] --sso-session [会话名] --no-browser
193+
```
194+
195+
该命令用于配置 SSO 类型 profile,会关联 SSO 会话并执行设备码授权流程,完成后写入 ~/.volcengine/config.json。支持的行为与参数说明:
196+
197+
```shell
198+
profile: profile 名称;未输入时使用 {sso-role-name}-{sso-account-id} 作为默认值
199+
sso-session: SSO 会话名称;未输入时进入交互式选择/创建模式
200+
no-browser: 禁止自动打开浏览器,默认 false
201+
```
202+
203+
注意事项:
204+
- 若指定的 profile 已存在且不是 SSO 类型,将拒绝覆盖并返回错误
205+
- 若 SSO 会话不存在,将引导创建,并要求输入 Start URL、Region 与 Scopes
206+
207+
208+
#### SSO 登录与登出
209+
210+
##### SSO 登录 (sso login)
211+
212+
```shell
213+
ve sso login --profile [配置名]
214+
#
215+
ve sso login --sso-session [会话名]
216+
```
217+
218+
该命令用于 SSO 登录,获取访问令牌并缓存。支持参数及说明:
219+
220+
```shell
221+
profile: 指定要使用的 SSO profile;必须存在且类型为 sso,且已配置 sso-session
222+
sso-session: 指定要使用的 SSO 会话;会话必须存在且有效
223+
no-browser: 禁止自动打开浏览器,默认 false
224+
```
225+
226+
登录行为说明:
227+
- 未指定 profile 和 sso-session 时:未配置任何会话会返回错误,仅有一个会话时直接使用该会话登录,有多个会话时进入交互式选择(可搜索筛选)
228+
- 当前仅支持设备码授权流程,`--no-browser` 用于关闭自动打开浏览器
229+
230+
##### SSO 登出 (sso logout)
231+
232+
```shell
233+
ve sso logout --sso-session [会话名]
234+
```
235+
236+
该命令用于退出 SSO 登录,撤销缓存的令牌并清除本地凭证。支持参数及说明:
237+
238+
```shell
239+
sso-session: 指定要退出的 SSO 会话名称
240+
```
241+
242+
登出行为说明:
243+
- 不指定 sso-session 时:未配置任何会话会返回错误,仅有一个会话时直接登出该会话,有多个会话时进入交互式选择,支持选择 “All SSO sessions” 批量登出
244+
- 选择批量登出时会逐个注销,并在有失败时汇总错误信息返回
167245

168246
#### 配置自动补全
169247

@@ -298,3 +376,4 @@ ve <service name> <action> [--parameter1 value1 --parameter2 value2 ...]
298376

299377

300378

379+

0 commit comments

Comments
 (0)