User Story
As a DevOps engineer, I want to use service accounts with qctl in CI/CD pipelines so I can automate deployments without interactive authentication.
Design
Command Interface
# Create service account token (via web UI or API)
# Token provided as environment variable or file
# Authenticate with service account
export QCTL_SERVICE_TOKEN=eyJhbGc...
qctl auth status
# Or via file
qctl auth login --service-account --token-file /path/to/token.json
# Or via environment
QCTL_TOKEN_FILE=/path/to/token.json qctl qrun publish
Service Account Token Format
{
"type": "service_account",
"account_id": "sa-abc123",
"account_name": "ci-deployer",
"organization": "acme-corp",
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_at": "2025-01-15T00:00:00Z",
"scopes": ["qctl:deploy", "qctl:read"]
}
Authentication Priority
1. QCTL_SERVICE_TOKEN environment variable (raw JWT)
2. QCTL_TOKEN_FILE environment variable (path to token file)
3. --token-file CLI argument
4. Interactive login tokens (from keychain)
CI/CD Examples
# GitHub Actions
- name: Deploy to production
env:
QCTL_SERVICE_TOKEN: ${{ secrets.QCTL_TOKEN }}
run: |
qctl qrun publish --env prod
# GitLab CI
deploy:
script:
- qctl auth login --service-account --token-file $QCTL_TOKEN_FILE
- qctl qrun publish --env prod
Files to Create/Modify
| File |
Action |
Purpose |
qctl-core/src/main/java/io/qrun/qctl/core/auth/ServiceAccountAuth.java |
Create |
SA authentication |
qctl-core/src/main/java/io/qrun/qctl/core/auth/TokenResolver.java |
Create |
Token resolution chain |
qctl-core/src/main/java/io/qrun/qctl/core/auth/model/ServiceAccount.java |
Create |
SA model |
qctl-core/src/main/java/io/qrun/qctl/core/auth/TokenManager.java |
Modify |
Add SA support |
qctl-core/src/main/java/io/qrun/qctl/core/auth/LoginCommand.java |
Modify |
Add --service-account |
Implementation Tasks
Acceptance Criteria
User Story
As a DevOps engineer, I want to use service accounts with qctl in CI/CD pipelines so I can automate deployments without interactive authentication.
Design
Command Interface
Service Account Token Format
{ "type": "service_account", "account_id": "sa-abc123", "account_name": "ci-deployer", "organization": "acme-corp", "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "expires_at": "2025-01-15T00:00:00Z", "scopes": ["qctl:deploy", "qctl:read"] }Authentication Priority
CI/CD Examples
Files to Create/Modify
qctl-core/src/main/java/io/qrun/qctl/core/auth/ServiceAccountAuth.javaqctl-core/src/main/java/io/qrun/qctl/core/auth/TokenResolver.javaqctl-core/src/main/java/io/qrun/qctl/core/auth/model/ServiceAccount.javaqctl-core/src/main/java/io/qrun/qctl/core/auth/TokenManager.javaqctl-core/src/main/java/io/qrun/qctl/core/auth/LoginCommand.javaImplementation Tasks
Acceptance Criteria
qctl auth statusshows service account info