---
name: step-04-perms
description: Synchronize permissions in Permissions.cs and PermissionConfiguration.cs
next_step: steps/step-05-validate.md
---

# Step 4: Synchronize Permissions

## YOUR TASK:

Add permissions to both Permissions.cs (constants) and PermissionConfiguration.cs (database seeds).

**CRITICAL: Both files MUST be in sync. Missing permissions = runtime 403 errors.**

---

## EXECUTION SEQUENCE:

### 1. Update Permissions.cs & PermissionConfiguration.cs

See [references/permission-sync-templates.md](../references/permission-sync-templates.md) for the C# templates:
- **Permissions.cs**: Nested class with 4 constants (View, Create, Update, Delete) + path-to-class mapping
- **PermissionConfiguration.cs**: 4 HasData Permission entries with Guid.NewGuid()

### 3. Generate Migration (Required)

**After updating PermissionConfiguration:**

```
IMPORTANT: New HasData entries require a migration!

Suggest command:
/efcore migration Add{module}Permissions
```

**If auto_mode:**
- Inform user that migration is needed
- Do NOT auto-run migration (user decision)

### 4. Validation Check

**Verify sync between files:**

| Permission Code | In Permissions.cs | In PermissionConfiguration.cs |
|-----------------|-------------------|------------------------------|
| `{permission_path}.read` | ✅ | ✅ |
| `{permission_path}.create` | ✅ | ✅ |
| `{permission_path}.update` | ✅ | ✅ |
| `{permission_path}.delete` | ✅ | ✅ |

### 5. Generate Postman Tests (if postman_mode)

**If {postman_mode} = true:**

See [references/permission-sync-templates.md](../references/permission-sync-templates.md) § "Postman API Test Template" for the JSON test collection template (200 OK + 403 Forbidden tests).

---

## OUTPUT FORMAT:

```
Permissions Synchronized:

| File | Changes |
|------|---------|
| Permissions.cs | Added {module} class with 4 constants |
| PermissionConfiguration.cs | Added 4 permission seeds |
| Postman Collection | Added {test_count} tests |

⚠️ MIGRATION REQUIRED:
Run: /efcore migration Add{module}Permissions

-> Validating build...
```

---

## NEXT STEP:

After permissions synced, proceed to `./step-05-validate.md`
