- Python 89.5%
- HTML 9.6%
- CSS 0.5%
- JavaScript 0.3%
- Shell 0.1%
|
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
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
|
||
|---|---|---|
| .forgejo/workflows | ||
| .s2i/bin | ||
| deploy | ||
| forgefiler | ||
| tests | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
| tox.ini | ||
| wsgi.py | ||
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
- User visits a direct link (e.g.,
/personal-data-request/file-issue) - Logs in with Fedora Account
- Fills out the form (title + custom questions)
- Issue is created in the private Forgejo repository
- User receives email confirmation with their submission
Requesting More Information
- Maintainer comments on the issue with
/respondfollowed by their message - Webhook fires → ForgeFiler sends email to the reporter
- Reporter clicks the link in the email
- Logs in and submits their response
- Response is added as a comment on the issue
- 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
- Create a
forgefiler-botuser in Forgejo - Add the bot as a collaborator to your private repositories (Write permission)
- Generate an API token: User Settings → Applications → Generate Token
- Use this token as
FORGEJO_BOT_TOKEN
2. Configure Webhooks
For each private repository:
- Go to Repository Settings → Webhooks → Add Webhook → Forgejo
- Configure:
- URL:
https://your-forgefiler-instance.com/webhooks/forgejo - Content Type:
application/json - Secret: Your
WEBHOOK_SECRETvalue - Events: Check "Issue comments" only
- Active: ✓ Enabled
- URL:
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_responsesare configured for the repository,/cannedis 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:
- Forgejo issues - Source of truth via API
- Signed session cookies - User authentication state
- 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