Skip to content

Commit 996c3ab

Browse files
committed
Refactor custom permissions: new 'config permissions' cmd
Major overhaul of custom blueprint permissions management: - Adds `a365 config permissions` subcommand for add/update/list/reset - Removes old permission flags from `config init` - Integrates improved permission step into interactive wizard - Updates all docs and tests to use new command/flags - Improves validation, error messages, and config file discovery - Refactors logic into PermissionsSubcommand.cs and adds helper methods - Adds comprehensive unit tests for CLI and wizard flows - Enhances UX: wizard re-prompts only for invalid scopes - CLI suggests next steps after permission changes This modernizes and simplifies custom API permission management for agent blueprints.
1 parent 566a3aa commit 996c3ab

12 files changed

Lines changed: 1219 additions & 276 deletions

File tree

docs/ai-workflows/integration-test-workflow.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ a365 config init --global
157157
#### Test 2.5: Configure Custom Blueprint Permissions
158158
```bash
159159
# Add Microsoft Graph extended permissions
160-
a365 config init --custom-blueprint-permissions \
161-
--resourceAppId 00000003-0000-0000-c000-000000000000 \
160+
a365 config permissions \
161+
--resource-app-id 00000003-0000-0000-c000-000000000000 \
162162
--scopes Presence.ReadWrite,Files.Read.All
163163

164164
# Expected: NO PROMPTS - permission added directly to a365.config.json
@@ -167,14 +167,14 @@ a365 config init --custom-blueprint-permissions \
167167
# Record: Custom permission added (Yes/No)
168168

169169
# View configured permissions
170-
a365 config init --custom-blueprint-permissions
170+
a365 config permissions
171171

172172
# Expected: Lists all configured custom permissions (may show appId only until setup runs)
173173
# Record: Permissions displayed correctly (Yes/No)
174174

175175
# Add second custom resource
176-
a365 config init --custom-blueprint-permissions \
177-
--resourceAppId 12345678-1234-1234-1234-123456789012 \
176+
a365 config permissions \
177+
--resource-app-id 12345678-1234-1234-1234-123456789012 \
178178
--scopes CustomScope.Read,CustomScope.Write
179179

180180
# Expected: NO PROMPTS - second permission added directly

docs/commands/config-init.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,31 @@ Azure location [westus]:
190190

191191
**Smart Defaults**: Uses location from existing config or Azure account
192192

193-
### Step 9: Configuration Summary
193+
### Step 9: Custom Blueprint Permissions (Optional)
194+
195+
Optionally configure custom resource permissions for your agent:
196+
197+
```
198+
=== Optional: Custom Blueprint Permissions ===
199+
If your agent needs access to additional external resources
200+
(e.g. Teams presence, OneDrive files, custom APIs) beyond
201+
standard permissions, you can configure them here.
202+
Most agents do not require this.
203+
204+
Configure custom blueprint permissions? (y/N): y
205+
206+
Resource App ID (GUID) - press Enter when done: 00000003-0000-0000-c000-000000000000
207+
Scopes (comma-separated, e.g. Presence.ReadWrite,Files.Read.All): Presence.ReadWrite,Files.Read.All
208+
Permission added.
209+
210+
Resource App ID (GUID) - press Enter when done:
211+
```
212+
213+
Press **Enter** with no input to finish and proceed.
214+
215+
> **Tip**: You can also add or update permissions after initial setup using `a365 config permissions`.
216+
217+
### Step 10: Configuration Summary
194218

195219
Review all settings before saving:
196220

@@ -212,11 +236,12 @@ App Service Plan : a365agent-app-plan
212236
Location : westus
213237
Subscription : My Subscription (e09e22f2-9193-4f54-a335-01f59575eefd)
214238
Tenant : adfa4542-3e1e-46f5-9c70-3df0b15b3f6c
239+
Custom Permissions : 1 configured
215240
216241
Do you want to customize any derived names? (y/N):
217242
```
218243

219-
### Step 10: Name Customization (Optional)
244+
### Step 11: Name Customization (Optional)
220245

221246
Optionally customize generated names:
222247

@@ -230,7 +255,7 @@ Agent User Principal Name [agent.myagent.11140916@yourdomain.onmicrosoft.com]:
230255
Agent User Display Name [myagent Agent User]:
231256
```
232257

233-
### Step 11: Confirmation
258+
### Step 12: Confirmation
234259

235260
Final confirmation to save:
236261

docs/commands/setup-permissions-custom.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The `a365 setup permissions custom` command applies custom API permissions to yo
1111

1212
```bash
1313
# Step 1: Configure custom permissions in config
14-
a365 config init --custom-blueprint-permissions \
15-
--resourceAppId 00000003-0000-0000-c000-000000000000 \
14+
a365 config permissions \
15+
--resource-app-id 00000003-0000-0000-c000-000000000000 \
1616
--scopes Presence.ReadWrite,Files.Read.All
1717

1818
# Step 2: Apply permissions to blueprint
@@ -34,24 +34,24 @@ a365 setup all
3434
## Prerequisites
3535

3636
1. **Blueprint Created**: Run `a365 setup blueprint` first to create the agent blueprint
37-
2. **Custom Permissions Configured**: Add custom permissions to `a365.config.json` using `a365 config init --custom-blueprint-permissions`
37+
2. **Custom Permissions Configured**: Add custom permissions to `a365.config.json` using `a365 config permissions`
3838
3. **Global Administrator**: You must have Global Administrator role to grant admin consent
3939

4040
## Configuration
4141

4242
### Step 1: Add Custom Permissions to Config
4343

44-
Use the `a365 config init --custom-blueprint-permissions` command to add custom permissions:
44+
Use the `a365 config permissions` command to add custom permissions:
4545

4646
```bash
4747
# Add Microsoft Graph extended permissions
48-
a365 config init --custom-blueprint-permissions \
49-
--resourceAppId 00000003-0000-0000-c000-000000000000 \
48+
a365 config permissions \
49+
--resource-app-id 00000003-0000-0000-c000-000000000000 \
5050
--scopes Presence.ReadWrite,Files.Read.All,Chat.Read
5151

5252
# Add custom API permissions
53-
a365 config init --custom-blueprint-permissions \
54-
--resourceAppId abcd1234-5678-90ab-cdef-1234567890ab \
53+
a365 config permissions \
54+
--resource-app-id abcd1234-5678-90ab-cdef-1234567890ab \
5555
--scopes CustomScope.Read,CustomScope.Write
5656
```
5757

@@ -171,8 +171,8 @@ a365 setup all
171171
**Solution**:
172172
```bash
173173
# Configure Microsoft Graph extended permissions
174-
a365 config init --custom-blueprint-permissions \
175-
--resourceAppId 00000003-0000-0000-c000-000000000000 \
174+
a365 config permissions \
175+
--resource-app-id 00000003-0000-0000-c000-000000000000 \
176176
--scopes Presence.ReadWrite,Files.Read.All
177177
```
178178

@@ -187,8 +187,8 @@ a365 config init --custom-blueprint-permissions \
187187
**Solution**:
188188
```bash
189189
# Configure Teams Chat permissions
190-
a365 config init --custom-blueprint-permissions \
191-
--resourceAppId 00000003-0000-0000-c000-000000000000 \
190+
a365 config permissions \
191+
--resource-app-id 00000003-0000-0000-c000-000000000000 \
192192
--scopes Chat.Read,Chat.ReadWrite,ChatMessage.Send
193193
```
194194

@@ -204,8 +204,8 @@ a365 config init --custom-blueprint-permissions \
204204
**Solution**:
205205
```bash
206206
# Configure custom API permissions
207-
a365 config init --custom-blueprint-permissions \
208-
--resourceAppId YOUR-CUSTOM-API-APP-ID \
207+
a365 config permissions \
208+
--resource-app-id YOUR-CUSTOM-API-APP-ID \
209209
--scopes api://your-api/Read,api://your-api/Write
210210
```
211211

@@ -221,13 +221,13 @@ a365 config init --custom-blueprint-permissions \
221221
**Solution**:
222222
```bash
223223
# Add first resource
224-
a365 config init --custom-blueprint-permissions \
225-
--resourceAppId 00000003-0000-0000-c000-000000000000 \
224+
a365 config permissions \
225+
--resource-app-id 00000003-0000-0000-c000-000000000000 \
226226
--scopes Presence.ReadWrite,Files.Read.All
227227

228228
# Add second resource (run command again)
229-
a365 config init --custom-blueprint-permissions \
230-
--resourceAppId YOUR-CUSTOM-API-APP-ID \
229+
a365 config permissions \
230+
--resource-app-id YOUR-CUSTOM-API-APP-ID \
231231
--scopes CustomScope.Read
232232

233233
# Apply all permissions
@@ -240,7 +240,7 @@ a365 setup permissions custom
240240

241241
```bash
242242
# View all configured custom permissions
243-
a365 config init --custom-blueprint-permissions
243+
a365 config permissions
244244
```
245245

246246
**Output**:
@@ -256,8 +256,8 @@ Current custom blueprint permissions:
256256

257257
```bash
258258
# Update scopes for an existing resource
259-
a365 config init --custom-blueprint-permissions \
260-
--resourceAppId 00000003-0000-0000-c000-000000000000 \
259+
a365 config permissions \
260+
--resource-app-id 00000003-0000-0000-c000-000000000000 \
261261
--scopes Presence.ReadWrite,Files.Read.All,Chat.Read
262262
```
263263

@@ -276,7 +276,7 @@ Configuration saved to: C:\Users\user\a365.config.json
276276

277277
```bash
278278
# Clear all custom permissions from config
279-
a365 config init --custom-blueprint-permissions --reset
279+
a365 config permissions --reset
280280
```
281281

282282
**Output**:
@@ -292,7 +292,7 @@ The CLI validates custom permissions at multiple stages:
292292

293293
### Config Validation
294294

295-
When adding permissions via `a365 config init`:
295+
When adding permissions via `a365 config permissions` (or the `a365 config init` wizard):
296296
-**GUID Format**: Resource App ID must be a valid GUID
297297
-**Required Fields**: Resource App ID (GUID) and scopes are required; resource name is optional and will be auto-resolved during setup if not provided
298298
-**Scopes**: At least one scope must be specified
@@ -313,10 +313,10 @@ When applying permissions via `a365 setup permissions custom`:
313313

314314
```
315315
WARNING: No custom blueprint permissions configured in a365.config.json
316-
Run 'a365 config init --custom-blueprint-permissions --resourceAppId <guid> --scopes <scopes>' to configure custom permissions.
316+
Run 'a365 config permissions --resource-app-id <guid> --scopes <scopes>' to configure custom permissions.
317317
```
318318

319-
**Solution**: Add custom permissions to config first using `a365 config init --custom-blueprint-permissions`
319+
**Solution**: Add custom permissions to config first using `a365 config permissions`
320320

321321
### Error: Blueprint Not Found
322322

@@ -340,7 +340,7 @@ ERROR: Invalid resourceAppId 'not-a-guid'. Must be a valid GUID format.
340340
### Error: Invalid Permission Configuration
341341

342342
```
343-
ERROR: Invalid custom permission configuration: resourceAppId must be a valid GUID, resourceName is required, At least one scope is required
343+
ERROR: Invalid custom permission configuration: resourceAppId must be a valid GUID, At least one scope is required
344344
```
345345

346346
**Solution**: Ensure all required fields are properly configured in `a365.config.json`
@@ -494,7 +494,7 @@ After configuring custom permissions:
494494

495495
1. **Test the agent**: Verify it can access the custom resources
496496
2. **Monitor usage**: Check Azure Portal for API call patterns
497-
3. **Update as needed**: Add or remove scopes using `a365 config init --custom-blueprint-permissions`
497+
3. **Update as needed**: Add or remove scopes using `a365 config permissions`
498498
4. **Deploy updates**: Run `a365 setup permissions custom` to apply changes
499499

500500
## Additional Resources

0 commit comments

Comments
 (0)