Commit fd9f8a3
Add spec for
Implement `tiger db create role` command
Adds a new command to create PostgreSQL database roles with enhanced safety features
for AI agents and automated tools.
Features:
- Create roles with auto-generated or explicit passwords
- Read-only enforcement via tsdb_admin.read_only_role for safe AI agent access
- Inherit permissions from existing roles with --from flag (supports multiple roles)
- Statement timeout configuration for query time limits
- Password storage integration (keyring/pgpass)
- Special handling for tsdbadmin inheritance using TimescaleDB Cloud functions
Implementation details:
- Uses transactions for atomic role creation and configuration
- Supports both standard PostgreSQL role creation and TimescaleDB Cloud special functions
- Handles --from tsdbadmin with timescale_functions.create_bare_readonly_role() and
timescale_functions.grant_tsdbadmin_to_role() to bypass ADMIN OPTION restrictions
- Validates that tsdbadmin inheritance requires --read-only flag
- Prevents SQL injection with proper identifier sanitization
- StringSliceVar for --from flag supporting both comma-separated and multiple flags
Testing:
- Comprehensive integration tests for all role creation scenarios
- Tests for read-only enforcement with table access verification
- Tests for role inheritance and permission grants
- SQL injection prevention tests
- Duplicate role name error handling
Documentation:
- Added detailed specifications in specs/spec.md
- Updated CLAUDE.md with development guidelines
- Created integration test helper script for easier testing
- Documented default permissions behavior and use cases
Fixes:
- Fixed authentication test failures by removing invalid --project-id flags
- Renamed TestServiceNotFound to TestServiceNotFoundIntegration for pattern matching
- Simplified test-integration.sh script from 84 to 31 lines following Unix philosophy
Co-authored-by: Claude <noreply@anthropic.com>tiger db create role command (#58)1 parent 5120c35 commit fd9f8a3
File tree
6 files changed
+1236
-13
lines changed- internal/tiger/cmd
- scripts
- specs
6 files changed
+1236
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
41 | 67 | | |
42 | 68 | | |
43 | 69 | | |
| |||
0 commit comments