Skip to content
Back to skills

3050 036 Bootstrap Custom Roles 98fdf334

ASecurity

- *Status:* Accepted - *Date:* 2026-01-25 - *Deciders:* Core Engineering Team

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 1, 2026
devopsgogitapidatabaseci/cdsecuritydocumentation

Works with

  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned June 1, 2026

npx -y skills add tools-only/X-Skills --skill 3050-036-bootstrap-custom-roles_98fdf334 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 3050 036 Bootstrap Custom Roles 98fdf334?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 3050 036 Bootstrap Custom Roles 98fdf334
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-3050-036-bootstrap-custom-roles-98fdf334/badge)](https://www.skillsdirectory.com/skills/tools-only-3050-036-bootstrap-custom-roles-98fdf334)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# ADR-0036: Bootstrap Custom Roles from Configuration File

- *Status:* Accepted
- *Date:* 2026-01-25
- *Deciders:* Core Engineering Team

## Context

Organizations deploying ContextForge need to pre-configure custom RBAC roles that match their organizational structure and access policies. Currently, the only way to create custom roles is through the Admin API after deployment, which creates additional manual steps and potential security gaps during the initial deployment window.

Common use cases requiring custom roles:

- **Data Analyst role**: Read-only access to tools and resources for data analysis workflows
- **Auditor role**: Global read access for compliance and security audits
- **CI/CD role**: Limited permissions for automation pipelines
- **Operator role**: Permissions to manage servers without full admin access

## Decision

We will allow administrators to define custom roles in a JSON configuration file that is automatically loaded during database bootstrap. The feature is:

1. **Disabled by default** - Requires explicit opt-in via `MCPGATEWAY_BOOTSTRAP_ROLES_IN_DB_ENABLED=true`
2. **File-based configuration** - Roles defined in a JSON file specified by `MCPGATEWAY_BOOTSTRAP_ROLES_IN_DB_FILE`
3. **Validated on load** - JSON structure is validated; invalid entries are skipped with warnings
4. **Idempotent** - Existing roles are detected and skipped; safe to run multiple times

### Configuration Schema

```json
[
  {
    "name": "role_name",          // Required: unique identifier
    "scope": "team|global",       // Required: access scope
    "permissions": ["..."],       // Required: array of permission strings
    "description": "...",         // Optional: human-readable description
    "is_system_role": true|false  // Optional: prevent user modification
  }
]
```

### File Resolution

When a relative path is provided:

1. Check current working directory
2. Check project root (`mcpgateway/bootstrap_db.py` → `parent.parent`)

### Error Handling

| Error Case | Behavior |
|------------|----------|
| File not found | Log warning, continue with default roles |
| Invalid JSON | Log error, continue with default roles |
| JSON is not an array | Log error, continue with default roles |
| Entry missing required keys | Skip entry with warning, process valid entries |
| Entry is not a dict | Skip entry with warning, process valid entries |

## Consequences

### Positive

- ✅ Organizations can pre-configure roles matching their access policies
- ✅ Eliminates manual role creation after deployment
- ✅ Supports GitOps workflows (roles defined in version control)
- ✅ Reduces security gap during initial deployment
- ✅ Graceful degradation on configuration errors

### Negative

- ❌ Adds complexity to bootstrap process
- ❌ Requires understanding of permission strings
- ❌ Configuration errors may go unnoticed if not monitoring logs

### Neutral

- 🔄 Roles can still be created/modified via Admin API after bootstrap
- 🔄 Feature is opt-in; no impact on existing deployments

## Alternatives Considered

| Option | Why Not |
|--------|---------|
| **Helm values only** | Not all deployments use Helm; need container-agnostic solution |
| **Environment variable per role** | Complex syntax for arrays of permissions; hard to manage |
| **Database seed scripts** | Requires DB access; doesn't integrate with bootstrap flow |
| **Admin API on startup** | Requires API to be available; chicken-and-egg problem |

## Security Considerations

1. **File access**: Configuration file should be mounted read-only
2. **Validation**: All entries are validated before processing
3. **No secrets**: Role definitions don't contain sensitive data
4. **Audit trail**: All role creation is logged

## Implementation

- `mcpgateway/config.py`: Add configuration settings
- `mcpgateway/bootstrap_db.py`: Add role loading and validation logic
- `tests/unit/mcpgateway/test_bootstrap_db.py`: Comprehensive test coverage

## Related

- [RBAC Configuration](../../manage/rbac.md) - End-user documentation
- Issue #2187 - Feature request
- PR #2188 - Implementation

Files in this skill

  • README.md909 B
  • skill.md4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.