diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..76b23ba
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,42 @@
+# Weekly dependency update PRs. Minor and patch updates are grouped into one
+# PR per ecosystem; major updates get their own PR so they can be reviewed.
+version: 2
+updates:
+ - package-ecosystem: cargo
+ directory: /
+ schedule:
+ interval: weekly
+ commit-message:
+ prefix: chore
+ include: scope
+ groups:
+ rust-minor:
+ update-types: [minor, patch]
+
+ - package-ecosystem: npm
+ directory: /web
+ schedule:
+ interval: weekly
+ commit-message:
+ prefix: chore
+ include: scope
+ groups:
+ web-minor:
+ update-types: [minor, patch]
+
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: weekly
+ commit-message:
+ prefix: ci
+ groups:
+ actions:
+ patterns: ["*"]
+
+ - package-ecosystem: docker
+ directory: /
+ schedule:
+ interval: weekly
+ commit-message:
+ prefix: build
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d4f60bd..adabc5c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,50 +1,164 @@
-name: Fast CI
+name: CI
on:
push:
- branches-ignore: [ "master", "main" ]
- paths:
- - 'src/**'
- - 'Cargo.toml'
- - 'Cargo.lock'
- - '.github/workflows/ci.yml'
+ branches: [ "main" ]
pull_request:
- branches-ignore: [ "master", "main" ]
- paths:
- - 'src/**'
- - 'Cargo.toml'
- - 'Cargo.lock'
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+# A new push to the same branch or PR cancels the run still in progress.
+concurrency:
+ group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
- check:
- name: Quick Check & Test
+ rust:
+ name: Rust (fmt, clippy, test)
+ runs-on: ubuntu-latest
+ timeout-minutes: 45
+ steps:
+ - uses: actions/checkout@v5
+
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@stable
+ with:
+ components: clippy, rustfmt
+
+ - name: Install system packages
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y cmake clang pkg-config libssl-dev
+
+ - uses: Swatinem/rust-cache@v2
+
+ - name: Formatting
+ run: cargo fmt --all -- --check
+
+ - name: Clippy (warnings are errors)
+ run: cargo clippy --all-targets --locked -- -D warnings
+
+ - name: Tests
+ run: cargo test --locked
+
+ msrv:
+ name: Rust 1.100 (minimum supported version)
+ runs-on: ubuntu-latest
+ timeout-minutes: 45
+ steps:
+ - uses: actions/checkout@v5
+
+ - name: Install Rust 1.100
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: "1.100"
+
+ - name: Install system packages
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y cmake clang pkg-config libssl-dev
+
+ - uses: Swatinem/rust-cache@v2
+
+ - name: Build
+ run: cargo check --all-targets --locked
+
+ web:
+ name: Web UI (lint, type-check, build)
runs-on: ubuntu-latest
+ timeout-minutes: 15
+ defaults:
+ run:
+ working-directory: web
+ steps:
+ - uses: actions/checkout@v5
+
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 24
+ cache: npm
+ cache-dependency-path: web/package-lock.json
+
+ - name: Install
+ run: npm ci
+ - name: Lint
+ run: npm run lint
+
+ - name: Type-check and build
+ run: npm run build
+
+ docker:
+ name: Docker image (build + smoke test)
+ # main is published by docker-image.yml; its PRs were already tested here.
+ if: github.event_name != 'push'
+ runs-on: ubuntu-latest
+ timeout-minutes: 60
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
- - name: Install Rust
- uses: dtolnay/rust-toolchain@stable
- with:
- components: clippy, rustfmt
+ - uses: docker/setup-buildx-action@v3
- - name: Install dependencies
- run: |
- sudo apt-get update
- sudo apt-get install -y cmake clang pkg-config libssl-dev
+ # amd64 only: the multi-arch build and push happen in docker-image.yml.
+ - name: Build
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ platforms: linux/amd64
+ load: true
+ push: false
+ tags: proxy-manager:ci
+ cache-from: type=gha,scope=ci-amd64
+ cache-to: type=gha,scope=ci-amd64,mode=max
- # 🔥 Magic Cache: Speeds up builds by 5-10x
- - name: Rust Cache
- uses: Swatinem/rust-cache@v2
+ - name: Start container
+ run: |
+ docker run -d --name pm \
+ -p 2030:2030 -p 8080:8080 \
+ -e PROXY_MANAGER_ADMIN_USERNAME=ci-admin \
+ -e PROXY_MANAGER_ADMIN_PASSWORD=ci-password \
+ -e JWT_SECRET=ci-secret \
+ proxy-manager:ci
- - name: Check Formatting
- run: cargo fmt -- --check
+ - name: Wait until healthy
+ run: |
+ for i in $(seq 1 60); do
+ status=$(docker inspect -f '{{.State.Health.Status}}' pm)
+ echo "health: $status"
+ [ "$status" = healthy ] && exit 0
+ [ "$(docker inspect -f '{{.State.Running}}' pm)" = true ] || break
+ sleep 2
+ done
+ docker logs pm
+ exit 1
- - name: Check Code (Clippy)
- run: cargo clippy --all-targets
+ - name: Smoke test
+ run: |
+ set -euo pipefail
+ # Dashboard is served
+ curl -fsS http://127.0.0.1:2030/ | grep -q '
'
+ # Admin from the environment can log in, the default cannot
+ token=$(curl -fsS -H 'Content-Type: application/json' \
+ -d '{"username":"ci-admin","password":"ci-password"}' \
+ http://127.0.0.1:2030/api/login | jq -r .token)
+ test -n "$token" && test "$token" != null
+ code=$(curl -s -o /dev/null -w '%{http_code}' -H 'Content-Type: application/json' \
+ -d '{"username":"admin","password":"changeme"}' http://127.0.0.1:2030/api/login)
+ test "$code" = 401
+ # Authenticated API works
+ curl -fsS -H "Authorization: Bearer $token" http://127.0.0.1:2030/api/hosts > /dev/null
+ # Proxy port answers (unknown host -> 404)
+ code=$(curl -s -o /dev/null -w '%{http_code}' -H 'Host: unknown.example' http://127.0.0.1:8080/)
+ test "$code" = 404
+ # Bundled tools are present
+ docker exec pm certbot --version
+ docker exec pm certbot plugins 2>/dev/null | grep -q dns-cloudflare
- - name: Run Tests
- run: cargo test
+ - name: Container logs
+ if: always()
+ run: docker logs pm 2>&1 | tail -100
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 41c8166..a97270c 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
with:
ref: ${{ inputs.tag || github.ref }}
@@ -56,7 +56,7 @@ jobs:
type=sha,format=short
- name: Build and push
- uses: docker/build-push-action@v5
+ uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml
new file mode 100644
index 0000000..24b98d7
--- /dev/null
+++ b/.github/workflows/security.yml
@@ -0,0 +1,51 @@
+name: Security audit
+
+# Checks dependencies against the RustSec and GitHub advisory databases.
+# Runs when dependencies change and weekly, since new advisories appear
+# for code that has not changed.
+on:
+ push:
+ branches: [ "main" ]
+ paths:
+ - 'Cargo.lock'
+ - 'deny.toml'
+ - 'web/package-lock.json'
+ - '.github/workflows/security.yml'
+ pull_request:
+ paths:
+ - 'Cargo.lock'
+ - 'deny.toml'
+ - 'web/package-lock.json'
+ - '.github/workflows/security.yml'
+ schedule:
+ - cron: '17 4 * * 1'
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+jobs:
+ rust:
+ name: Rust advisories (cargo-deny)
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@v5
+ - uses: EmbarkStudios/cargo-deny-action@v2
+ with:
+ command: check advisories
+
+ web:
+ name: npm advisories (production dependencies)
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ defaults:
+ run:
+ working-directory: web
+ steps:
+ - uses: actions/checkout@v5
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 24
+ - name: npm audit
+ run: npm audit --omit=dev --audit-level=high
diff --git a/.github/workflows/semantic-pr-title.yml b/.github/workflows/semantic-pr-title.yml
index 5bee87c..2b7a96b 100644
--- a/.github/workflows/semantic-pr-title.yml
+++ b/.github/workflows/semantic-pr-title.yml
@@ -1,7 +1,9 @@
name: Semantic PR Title
+# pull_request (not pull_request_target): checking the title only needs read
+# access, and this never runs workflow code from the base branch with write access.
on:
- pull_request_target:
+ pull_request:
types:
- opened
- edited
diff --git a/deny.toml b/deny.toml
new file mode 100644
index 0000000..60d8961
--- /dev/null
+++ b/deny.toml
@@ -0,0 +1,9 @@
+# cargo-deny configuration (used by .github/workflows/security.yml).
+# Run locally with: cargo deny check advisories
+
+[advisories]
+ignore = [
+ # chrono is marked unmaintained (no known vulnerability). It is required by
+ # pingora itself, so it cannot be dropped until pingora moves off it.
+ { id = "RUSTSEC-2026-0543", reason = "unmaintained, no vulnerability; required by pingora" },
+]
diff --git a/docs/Contributing-Guide.md b/docs/Contributing-Guide.md
index 9a1fdef..e76da6d 100644
--- a/docs/Contributing-Guide.md
+++ b/docs/Contributing-Guide.md
@@ -19,7 +19,7 @@ Please be respectful and professional in all interactions.
1. Fork the repository.
2. Create a new branch for your feature or bugfix (`git checkout -b feature/awesome-feature`).
3. Make your changes.
-4. Run checks and tests (`cargo fmt -- --check`, `cargo clippy --all-targets`, `cargo test`).
+4. Run the same checks CI runs (see [Development Setup](Development-Setup.md#testing)).
5. Commit your changes (`git commit -m 'Add some awesome feature'`).
6. Push to the branch (`git push origin feature/awesome-feature`).
7. Open a Pull Request.
@@ -38,8 +38,18 @@ Please be respectful and professional in all interactions.
- Follow the existing component structure in `web/src/components`.
## Build & CI
-- Every PR will trigger a GitHub Action to build the server and web UI.
-- Ensure the build passes before asking for a review.
+Every pull request runs these checks (`.github/workflows/ci.yml`); all must pass before review:
+
+| Check | What it runs |
+| :--- | :--- |
+| Rust | `cargo fmt --check`, `cargo clippy -- -D warnings` (warnings fail the build), `cargo test` |
+| Rust 1.100 | `cargo check` on the minimum supported Rust version |
+| Web UI | `npm run lint` and `npm run build` (type-check + production build) |
+| Docker | builds the image, starts it and smoke-tests login, the API, the proxy port and certbot |
+
+`.github/workflows/security.yml` checks Rust and npm dependencies for known vulnerabilities whenever the lockfiles change and every Monday. Dependabot opens weekly dependency update PRs (`.github/dependabot.yml`).
+
+PR titles must follow [Conventional Commits](https://www.conventionalcommits.org/) (`feat: ...`, `fix: ...`), since release-please builds releases from them.
---
Thank you for your contribution!
diff --git a/docs/Development-Setup.md b/docs/Development-Setup.md
index 0fd89ff..fb2c72e 100644
--- a/docs/Development-Setup.md
+++ b/docs/Development-Setup.md
@@ -44,11 +44,27 @@ Follow these instructions to set up a local development environment.
4. Access the dashboard at `http://localhost:5173`. The Vite dev server is configured to proxy `/api` requests to `localhost:2030`.
## Testing
-### Server Tests
+These are the checks CI runs on every pull request.
+
+### Server
+```bash
+cargo fmt --all -- --check
+cargo clippy --all-targets --locked -- -D warnings
+cargo test --locked
+```
+
+### Web UI
+```bash
+cd web
+npm run lint
+npm run build
+```
+
+### Dependency audit
```bash
-cargo fmt -- --check
-cargo clippy --all-targets
-cargo test
+cargo install cargo-deny --locked # once
+cargo deny check advisories # uses deny.toml
+cd web && npm audit --omit=dev
```
### Docker Build Test
diff --git a/src/acme.rs b/src/acme.rs
index 6b9cf84..6a0fd24 100644
--- a/src/acme.rs
+++ b/src/acme.rs
@@ -1,9 +1,7 @@
use crate::db::{self, DbPool};
-use crate::state::AppState;
use std::error::Error;
use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf};
-use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use tokio::fs;
use tokio::process::Command; // Import for setting file permissions
@@ -29,15 +27,13 @@ pub fn http01_token_path(token: &str) -> Option
{
}
pub struct AcmeManager {
- state: Arc,
db_pool: DbPool,
contact_email: String,
}
impl AcmeManager {
- pub fn new(state: Arc, db_pool: DbPool, email: String) -> Self {
+ pub fn new(db_pool: DbPool, email: String) -> Self {
Self {
- state,
db_pool,
contact_email: email,
}
diff --git a/src/api/handlers/certs.rs b/src/api/handlers/certs.rs
index 842e0ef..13e2efd 100644
--- a/src/api/handlers/certs.rs
+++ b/src/api/handlers/certs.rs
@@ -39,11 +39,7 @@ pub async fn request_cert(
)
.await;
- let manager = AcmeManager::new(
- state.app_state.clone(),
- state.db_pool.clone(),
- payload.email,
- );
+ let manager = AcmeManager::new(state.db_pool.clone(), payload.email);
tokio::spawn(async move {
if let Err(e) = manager
.request_certificate(&payload.domain, payload.provider_id)
diff --git a/src/api/handlers/stats.rs b/src/api/handlers/stats.rs
index be952ba..2da52c4 100644
--- a/src/api/handlers/stats.rs
+++ b/src/api/handlers/stats.rs
@@ -66,8 +66,11 @@ pub async fn get_logs(
Ok(Json(lines))
}
-pub async fn get_error_page(_: Claims) -> String {
- fs::read_to_string("data/templates/error.html").unwrap_or_default()
+const ERROR_PAGE_PATH: &str = "data/templates/error.html";
+
+/// Returns the error page currently in use (the built-in default until one is saved).
+pub async fn get_error_page(_: Claims, State(state): State) -> String {
+ state.app_state.error_template.load().as_ref().clone()
}
pub async fn update_error_page(
@@ -82,7 +85,11 @@ pub async fn update_error_page(
));
}
- fs::write("data/templates/error.html", &payload.html)?;
+ // data/templates/ does not exist on a fresh install.
+ if let Some(dir) = Path::new(ERROR_PAGE_PATH).parent() {
+ fs::create_dir_all(dir)?;
+ }
+ fs::write(ERROR_PAGE_PATH, &payload.html)?;
// Audit log
let _ = db::insert_audit_log(
diff --git a/src/auth.rs b/src/auth.rs
index f3264d0..4413455 100644
--- a/src/auth.rs
+++ b/src/auth.rs
@@ -51,14 +51,6 @@ impl Role {
_ => Role::Viewer,
}
}
-
- pub fn to_str(&self) -> &'static str {
- match self {
- Role::Admin => "admin",
- Role::Operator => "operator",
- Role::Viewer => "viewer",
- }
- }
}
impl Claims {
@@ -73,16 +65,10 @@ impl Claims {
pub fn can_manage_hosts(&self) -> bool {
self.role() >= Role::Operator
}
-
- pub fn can_manage_users(&self) -> bool {
- self.role() == Role::Admin
- }
}
#[derive(Debug)]
pub enum AuthError {
- WrongCredentials,
- MissingCredentials,
TokenCreation,
InvalidToken,
InternalServerError,
@@ -91,8 +77,6 @@ pub enum AuthError {
impl IntoResponse for AuthError {
fn into_response(self) -> Response {
let (status, error_message) = match self {
- AuthError::WrongCredentials => (StatusCode::UNAUTHORIZED, "Wrong credentials"),
- AuthError::MissingCredentials => (StatusCode::BAD_REQUEST, "Missing credentials"),
AuthError::TokenCreation => (StatusCode::INTERNAL_SERVER_ERROR, "Token creation error"),
AuthError::InvalidToken => (StatusCode::UNAUTHORIZED, "Invalid token"),
AuthError::InternalServerError => {
@@ -136,11 +120,6 @@ pub fn create_jwt(username: &str, user_id: i64, role: &str) -> Result Result {
- create_jwt(username, 0, "admin")
-}
-
// JWT verification (Axum extractor)
impl FromRequestParts for Claims
where
diff --git a/src/constants.rs b/src/constants.rs
index 4dbf0a8..ebed0be 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -7,7 +7,6 @@ pub mod http {
pub const NOT_FOUND: u16 = StatusCode::NOT_FOUND.as_u16();
pub const INTERNAL_ERROR: u16 = StatusCode::INTERNAL_SERVER_ERROR.as_u16();
pub const UNAUTHORIZED: u16 = StatusCode::UNAUTHORIZED.as_u16();
- pub const CREATED: u16 = StatusCode::CREATED.as_u16();
pub const PAYLOAD_TOO_LARGE: u16 = StatusCode::PAYLOAD_TOO_LARGE.as_u16();
}
@@ -23,7 +22,8 @@ pub mod network {
pub mod cert {
pub const RSA_BITS: u32 = 2048;
pub const VALIDITY_DAYS: u32 = 3650; // 10 years
- pub const RENEWAL_THRESHOLD_DAYS: u64 = 30;
+ /// Seconds a loaded certificate is cached before being re-read from disk.
+ pub const CACHE_TTL_SECS: u64 = 300;
}
/// Timeouts (milliseconds/seconds)
diff --git a/src/db/access_lists.rs b/src/db/access_lists.rs
index f5b5946..82c3c13 100644
--- a/src/db/access_lists.rs
+++ b/src/db/access_lists.rs
@@ -8,7 +8,6 @@ pub struct AccessListRow {
#[derive(sqlx::FromRow, Debug, Clone)]
pub struct AccessListClientRow {
- pub id: i64,
pub list_id: i64,
pub username: String,
pub password_hash: String,
@@ -16,7 +15,6 @@ pub struct AccessListClientRow {
#[derive(sqlx::FromRow, Debug, Clone)]
pub struct AccessListIpRow {
- pub id: i64,
pub list_id: i64,
pub ip_address: String,
pub action: String, // 'allow' or 'deny'
diff --git a/src/db/certs.rs b/src/db/certs.rs
index 50acade..6298e06 100644
--- a/src/db/certs.rs
+++ b/src/db/certs.rs
@@ -51,21 +51,6 @@ pub async fn upsert_cert(
Ok(())
}
-/// Retrieves a certificate record by domain name.
-///
-/// # Arguments
-/// * `pool` - Database connection pool
-/// * `domain` - Domain name
-///
-/// # Returns
-/// * `Result