A small flask web app for filing tickets on specific Private repos on Fedora Forge
  • Python 89.5%
  • HTML 9.6%
  • CSS 0.5%
  • JavaScript 0.3%
  • Shell 0.1%
Find a file
Ryan Lerch 86e9ee3db6
All checks were successful
Run tests / isort (pull_request) Successful in 43s
Run tests / flake8 (pull_request) Successful in 43s
Run tests / bandit (pull_request) Successful in 43s
Run tests / black (pull_request) Successful in 43s
Run tests / pyupgrade (pull_request) Successful in 40s
Run tests / Tests (Python 3.14) (pull_request) Successful in 1m34s
Run tests / Tests (Python 3.13) (pull_request) Successful in 1m34s
Run tests / Tests (Python 3.12) (pull_request) Successful in 1m34s
Run tests / Tests (Python 3.9) (pull_request) Successful in 1m14s
Deploy / deploy (push) Successful in 2s
Add /canned command for predefined template responses
Maintainers can now use /canned <name> to send predefined template
messages to reporters. Templates are configured per repository in the
canned_responses section of the config.

Example configuration:
  canned_responses = {
      "received": "We have received your request...",
      "completed": "Your request has been processed..."
  }

Example usage:
  /canned received
  /canned completed

Implements: #11
2026-09-07 03:05:36 +00:00
.forgejo/workflows Install nodejs for actions/checkout in promote workflow 2026-08-17 13:57:07 +10:00
.s2i/bin Fix version footer: use OPENSHIFT_BUILD_COMMIT env var 2026-08-17 20:29:07 +10:00
deploy Add show_attachments config option to disable file uploads per repository 2026-08-17 11:25:17 +10:00
forgefiler Add /canned command for predefined template responses 2026-09-07 03:05:36 +00:00
tests Add /canned command for predefined template responses 2026-09-07 03:05:36 +00:00
.gitignore Add coverage.xml to .gitignore 2026-07-24 14:14:05 +10:00
.pre-commit-config.yaml Add pre-commit, tox, and linting/security tooling 2026-07-23 12:41:17 +10:00
poetry.lock Remove liccheck, fix tox config for tox 4 2026-07-24 13:58:44 +10:00
pyproject.toml Remove liccheck, fix tox config for tox 4 2026-07-24 13:58:44 +10:00
README.md Add /canned command for predefined template responses 2026-09-07 03:05:36 +00:00
tox.ini Add multi-Python tox matrix and Forgejo Actions CI workflow 2026-07-24 14:12:31 +10:00
wsgi.py Add pre-commit, tox, and linting/security tooling 2026-07-23 12:41:17 +10:00

ForgeFiler

A Flask application for filing issues in private Forgejo repositories.

Overview

ForgeFiler enables users to file issues in private Forgejo repositories they don't have direct access to, such as for Code of Conduct violations, privacy requests, or security issues.

Key Features:

  • No database required - Forgejo issues are the source of truth
  • Fedora Account authentication - OIDC integration via Authlib
  • Two-way communication - Maintainers can request additional info from reporters
  • Email notifications - Users receive confirmations and updates via email
  • File attachments - Support for images, PDFs, and text files (up to 5 files, 10MB each)
  • Custom questions - Configure specific questions per repository
  • Privacy-focused - Issue numbers never exposed to reporters

How It Works

Filing an Issue

  1. User visits a direct link (e.g., /personal-data-request/file-issue)
  2. Logs in with Fedora Account
  3. Fills out the form (title + custom questions)
  4. Issue is created in the private Forgejo repository
  5. User receives email confirmation with their submission

Requesting More Information

  1. Maintainer comments on the issue with /respond followed by their message
  2. Webhook fires → ForgeFiler sends email to the reporter
  3. Reporter clicks the link in the email
  4. Logs in and submits their response
  5. Response is added as a comment on the issue
  6. Reporter receives email confirmation

Development Setup

Prerequisites

  • Python 3.9+
  • Poetry
  • A Forgejo instance with API access
  • Fedora Account OIDC credentials (or use dev mode)

Installation

cd ForgeFiler

# Install dependencies
poetry install

# Copy example config
cp deploy/forgefiler.toml.example forgefiler.toml

# Edit configuration
$EDITOR forgefiler.toml

Configuration

Edit forgefiler.toml:

Required settings:

# URLs
application_url = "http://localhost:5000"
forgejo_url = "https://forge.fedoraproject.org"

# SMTP (for email notifications)
smtp_server = "localhost"
smtp_port = 25
from_email = "forgefiler@example.com"

# Repositories
[[repositories]]
id = "coc-violations"
owner = "fedora"
name = "coc-private"
display_name = "Code of Conduct Violations"
description = "Report CoC violations"
maintainer_emails = ["admin@example.com"]

# Optional: Custom questions
questions = [
    "What happened?",
    "When did this occur?",
    "Who was involved?"
]

Secrets (required):

Secrets can be in the TOML file or environment variables:

# Option 1: In forgefiler.toml (development)
secret_key = "your-random-secret-key"
forgejo_bot_token = "your-forgejo-api-token"
webhook_secret = "your-webhook-secret"
# Option 2: Environment variables (production)
export SECRET_KEY="..."
export FORGEJO_BOT_TOKEN="..."
export WEBHOOK_SECRET="..."

Generate secrets:

python3 -c 'import secrets; print(secrets.token_hex(32))'

OIDC (optional for dev):

fedora_client_id = "your-client-id"
fedora_client_secret = "your-client-secret"

Or enable dev mode to skip authentication:

dev_mode = true

Running Locally

export FORGEFILER_CONFIG=forgefiler.toml

# Development server
poetry run flask --app 'forgefiler.app:create_app()' run --debug

# Production-like (Gunicorn)
poetry run gunicorn -c deploy/gunicorn.conf.py 'forgefiler.app:create_app()'

Visit http://localhost:5000

Forgejo Setup

1. Create Bot Account

  1. Create a forgefiler-bot user in Forgejo
  2. Add the bot as a collaborator to your private repositories (Write permission)
  3. Generate an API token: User Settings → Applications → Generate Token
  4. Use this token as FORGEJO_BOT_TOKEN

2. Configure Webhooks

For each private repository:

  1. Go to Repository Settings → Webhooks → Add Webhook → Forgejo
  2. Configure:
    • URL: https://your-forgefiler-instance.com/webhooks/forgejo
    • Content Type: application/json
    • Secret: Your WEBHOOK_SECRET value
    • Events: Check "Issue comments" only
    • Active: ✓ Enabled

3. Using the /respond Command

Maintainers request more info by commenting:

/respond
Can you provide more details about when this happened?

The reporter will receive an email with a secure link to respond.

4. Using the /canned Command

Maintainers can send predefined template messages by using the /canned command:

/canned gotit

This sends the gotit template message to the reporter. Templates are configured per repository in forgefiler.toml:

[[repositories]]
id = "personal-data-request"
owner = "fedora"
name = "pdr-private"
display_name = "Personal Data Request"
maintainer_emails = ["admin@example.com"]

[repositories.canned_responses]
gotit = "We have received your request and will process it within 5 business days. You do not need to take any further action at this time."
processed = "Your request has been processed and is now complete. If you have any further questions, please file a new request."
needinfo = "We need additional information to process your request. Please provide more details about what you're requesting."

Behavior:

  • If the template name doesn't exist, the command is silently ignored
  • If no canned_responses are configured for the repository, /canned is ignored
  • The reporter receives the same email format as /respond, including the reply link

Architecture

Stateless Design

ForgeFiler requires no database. All state lives in:

  1. Forgejo issues - Source of truth via API
  2. Signed session cookies - User authentication state
  3. Signed URL tokens - Response flow tokens

Token Security

Response tokens are cryptographically signed with itsdangerous.URLSafeSerializer:

payload = {"repo_id": "...", "issue_number": 42}
token = URLSafeSerializer(SECRET_KEY).dumps(payload)

Security properties:

  • Cannot be forged without SECRET_KEY
  • User must authenticate via OIDC to use the token
  • System verifies the logged-in user matches the original reporter
  • Tokens don't expire (they're identifiers, not credentials)

Privacy

Issue numbers are never shown to reporters:

  • Subject lines contain only repository name and issue title
  • Message-IDs use signed tokens instead of issue numbers
  • Response URLs use signed tokens

Development

Setting Up Pre-commit Hooks

Install the pre-commit hooks so checks run automatically on each commit:

poetry run pre-commit install

To run all checks manually without committing:

poetry run pre-commit run --all-files

Running Tests and Checks

Use tox to run the full test and check suite:

# Run everything (checks, tests, coverage)
tox

# Run just the linting/formatting checks (pre-commit hooks)
tox -e checks

# Run just the tests
tox -e unittest

# Run tests with coverage report
tox -e covclean,unittest,covreport

Or run tests directly with pytest:

poetry run pytest
poetry run pytest tests/test_tokens.py -v

What the Checks Cover

  • pyupgrade — automatically modernizes Python syntax
  • black — code formatting (line length 100)
  • isort — import sorting (black-compatible profile)
  • flake8 — style and error linting
  • bandit — security linting (skips test files)

Health Checks

  • /healthz/live - Basic application health
  • /healthz/ready - Forgejo API connectivity check

Configuration Reference

Repository Configuration

[[repositories]]
id = "unique-id"                    # Used in URLs (e.g., /unique-id/file-issue)
owner = "forgejo-username"          # Repository owner
name = "repo-name"                  # Repository name
display_name = "Display Name"       # Shown to users
description = "Description text"    # Shown on issue form
maintainer_emails = ["..."]         # Who gets Forgejo notifications
questions = ["Q1", "Q2"]           # Optional: custom questions (defaults to "Body")

# Optional: Canned responses for /canned command
[repositories.canned_responses]
template_name = "Message text to send to reporter"
another_template = "Another predefined message"

Application Settings

application_url = "https://..."     # Your ForgeFiler URL
forgejo_url = "https://..."         # Your Forgejo instance
smtp_server = "localhost"           # SMTP server for emails
smtp_port = 25                      # SMTP port
from_email = "forgefiler@..."       # From address for emails
dev_mode = false                    # Enable fake auth (dev only)

License

MIT License