[Security] Develop an Automatic Token Rotation Script for Gitea Agent Credentials #1421

Closed
opened 2026-03-24 13:04:37 +00:00 by Timmy · 1 comment
Owner

Context: Gitea API tokens possess no automated expiry loop.

Acceptance Criteria:

  • Integrate a 30-day token rotation protocol using Gitea integration commands.
  • Revoke previous token post-rotation.
**Context:** Gitea API tokens possess no automated expiry loop. **Acceptance Criteria:** - Integrate a 30-day token rotation protocol using Gitea integration commands. - Revoke previous token post-rotation.
Author
Owner

Implementation Plan for Token Rotation Script

Priority: HIGH - Security vulnerability (plaintext tokens with no rotation)

Files to Create/Modify:

  1. scripts/rotate-gitea-tokens.sh - Main rotation script
  2. scripts/ops-helpers.sh - Add token rotation helper function
  3. .github/workflows/token-rotation.yml or cron job setup

Implementation Steps:

  1. Create Token Rotation Script (scripts/rotate-gitea-tokens.sh):

    • Generate new Gitea API token via API call
    • Update ~/.hermes/gitea_token atomically (write to temp file, then rename)
    • Revoke old token via API
    • Log rotation events with timestamps
    • Include error handling and rollback on failure
  2. Add Ops Helper Function (scripts/ops-helpers.sh):

    • Add rotate_gitea_token() function
    • Include validation for token format and permissions
    • Add verify_token_permissions() helper
  3. Automation Setup:

    • Create cron job or GitHub Action for weekly rotation
    • Include notification on rotation failure
    • Test in staging environment first

Key Security Requirements:

  • Atomic file operations (no partial writes)
  • Proper file permissions (600 for token files)
  • Secure cleanup of old tokens
  • Comprehensive error logging
  • Rollback capability on failure

Testing:

  • Verify new token works before revoking old one
  • Test with invalid credentials
  • Test file permission scenarios
  • Verify cron job integration

Acceptance Criteria Met When:

  • Script successfully rotates tokens without service interruption
  • Old tokens are properly revoked
  • Process is fully automated (weekly cron job)
  • Comprehensive error handling and logging
  • Documentation updated

This addresses a critical security gap - plaintext tokens with no expiry/rotation cycle.

## Implementation Plan for Token Rotation Script **Priority**: HIGH - Security vulnerability (plaintext tokens with no rotation) **Files to Create/Modify**: 1. `scripts/rotate-gitea-tokens.sh` - Main rotation script 2. `scripts/ops-helpers.sh` - Add token rotation helper function 3. `.github/workflows/token-rotation.yml` or cron job setup **Implementation Steps**: 1. **Create Token Rotation Script** (`scripts/rotate-gitea-tokens.sh`): - Generate new Gitea API token via API call - Update `~/.hermes/gitea_token` atomically (write to temp file, then rename) - Revoke old token via API - Log rotation events with timestamps - Include error handling and rollback on failure 2. **Add Ops Helper Function** (`scripts/ops-helpers.sh`): - Add `rotate_gitea_token()` function - Include validation for token format and permissions - Add `verify_token_permissions()` helper 3. **Automation Setup**: - Create cron job or GitHub Action for weekly rotation - Include notification on rotation failure - Test in staging environment first **Key Security Requirements**: - Atomic file operations (no partial writes) - Proper file permissions (600 for token files) - Secure cleanup of old tokens - Comprehensive error logging - Rollback capability on failure **Testing**: - Verify new token works before revoking old one - Test with invalid credentials - Test file permission scenarios - Verify cron job integration **Acceptance Criteria Met When**: - Script successfully rotates tokens without service interruption - Old tokens are properly revoked - Process is fully automated (weekly cron job) - Comprehensive error handling and logging - Documentation updated This addresses a critical security gap - plaintext tokens with no expiry/rotation cycle.
kimi was assigned by Timmy 2026-03-24 14:45:21 +00:00
kimi was unassigned by Timmy 2026-03-24 19:32:17 +00:00
Timmy closed this issue 2026-03-24 21:54:07 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1421