Commit graph

74 commits

Author SHA1 Message Date
Stefano Bertelli
2f63f4cd17 Merge branch 'main' into dev
All checks were successful
Dev / test (push) Successful in 1m22s
Dev / release (push) Successful in 37s
Dev / docker (push) Has been skipped
2026-05-09 11:46:19 -05:00
cca49ca2cf fix: prevent collector subprocess from deadlocking on full pipe buffer
All checks were successful
Dev / test (push) Successful in 1m13s
Dev / release (push) Successful in 41s
Dev / docker (push) Has been skipped
Collector was spawned with stdout=PIPE but nobody read from the pipe.
After days of accumulated log output the OS buffer filled, blocking
the collector and freezing all metrics updates.
2026-04-07 17:48:36 -05:00
Stefano Bertelli
31b31b7946 ci: exclude weak-sensitive-data-hashing rule from CodeQL
API token hashing uses HMAC-SHA256 on high-entropy tokens (256-bit
random), not passwords. Actual password hashing uses bcrypt.
2026-04-03 00:55:01 -05:00
Stefano Bertelli
604446f8ca fix: use HMAC-SHA256 with secret key for API token hashing 2026-04-03 00:51:38 -05:00
Stefano Bertelli
496334137d fix: replace python-jose with PyJWT to eliminate vulnerable ecdsa dependency 2026-04-03 00:46:36 -05:00
Stefano Bertelli
5c02598a46 fix: address CodeQL findings — sha512 for token hashing, secure tempfile 2026-04-03 00:41:16 -05:00
Stefano Bertelli
aa38c3797e ci: add security policy, CodeQL scanning, enable Dependabot 2026-04-03 00:35:42 -05:00
Stefano Bertelli
87989b899d fix(ci): add contents:write permission for release job to push tags 2026-04-03 00:03:44 -05:00
Stefano Bertelli
bde7a82224 fix(ci): remove container from release job, use ubuntu-latest directly 2026-04-02 23:58:22 -05:00
Stefano Bertelli
aaddb319bc fix(ci): add valkey, mock-oidc services and MOCK_OIDC_HOST env for e2e tests 2026-04-02 23:52:01 -05:00
Stefano Bertelli
2a83cead67 Merge branch 'refs/heads/dev'
All checks were successful
CI / test (push) Successful in 1m5s
CI / release (push) Successful in 36s
CI / docker (push) Has been skipped
2026-04-02 23:43:48 -05:00
Stefano Bertelli
b3f23fd00d fix(ci): install Playwright browsers before e2e tests 2026-04-02 23:39:08 -05:00
Stefano Bertelli
c94b2ed76c ci: add GitHub Actions workflows mirroring Forgejo CI/CD 2026-04-02 23:35:56 -05:00
Stefano Bertelli
0babff823a fix: cleanup
All checks were successful
Dev / test (push) Successful in 1m20s
Dev / release (push) Successful in 35s
Dev / docker (push) Has been skipped
2026-04-01 00:34:12 -05:00
Stefano Bertelli
1af3773656 fix: gitignore 2026-04-01 00:34:02 -05:00
Stefano Bertelli
897fac08bc chore: logging defaults not to file
chore: small improvements in Makefile
2026-04-01 00:33:16 -05:00
Stefano Bertelli
4633853990 fix: mock _list_user_chains in rebuild_all_rules test
All checks were successful
Dev / test (push) Successful in 1m53s
Dev / release (push) Successful in 34s
Dev / docker (push) Has been skipped
2026-03-31 23:44:45 -05:00
Stefano Bertelli
0edfc75821 feat: replace custom versioning with python-semantic-release
Some checks failed
Dev / test (push) Failing after 1m19s
Dev / release (push) Has been skipped
Dev / docker (push) Has been skipped
Configure python-semantic-release for automated changelog and
versioning: rc releases on dev branch, stable releases on main.
Remove the custom bash version-bump and changelog scripts from
both CI pipelines.
2026-03-31 23:36:42 -05:00
Stefano Bertelli
260837d3aa fix: clean up orphaned nftables chains on reconcile
Some checks failed
Dev / test (push) Failing after 1m15s
Dev / docker (push) Has been skipped
rebuild_all_rules now discovers existing user_ chains and removes any
that are no longer in the DB. Reconcile always runs the firewall
rebuild even with 0 devices, so stale forward rules and orphan chains
are cleaned up when all devices are deleted.
2026-03-31 23:25:30 -05:00
Stefano Bertelli
0f5e517f9d chore: disable e2e tests in CI, add TODO to fix
All checks were successful
Dev / test (push) Successful in 1m25s
Dev / docker (push) Successful in 2m8s
E2E tests pass locally but fail in the Forgejo Actions container
environment. Disabled until the root cause is resolved.
2026-03-31 22:44:34 -05:00
Stefano Bertelli
877861c9e8 fix: restore original conftest.py from last working state
Some checks failed
Dev / test (push) Failing after 4m17s
Dev / docker (push) Has been skipped
Revert to the exact per-test create/drop conftest that worked at
25cff5e4. The session-scoped and module-level patching approaches
both broke e2e tests in CI.
2026-03-31 22:40:09 -05:00
Stefano Bertelli
554da599ba fix: stop patching wiregui.db globally — broke e2e tests
Some checks failed
Dev / test (push) Failing after 4m3s
Dev / docker (push) Has been skipped
Remove module-level engine/session replacement that affected all tests
including e2e. The test engine is now only used via the session fixture,
so e2e tests keep using the real DB the app writes to.
2026-03-31 22:14:34 -05:00
Stefano Bertelli
8cf16c7f91 fix: skip SAML browser-redirect tests in CI
Some checks failed
Dev / test (push) Failing after 7m30s
Dev / docker (push) Has been skipped
Chromium cannot resolve Docker service hostnames (mock-saml) in CI.
Skip the two tests that require browser navigation to the IdP; the
other SAML tests (button visibility, SP metadata) still run.
2026-03-31 21:55:15 -05:00
Stefano Bertelli
edb25e83be fix: increase SAML redirect timeout and add mock-saml health check
Some checks failed
Dev / test (push) Failing after 8m10s
Dev / docker (push) Has been skipped
SAML e2e tests were timing out in CI waiting for the IdP redirect.
Increase Playwright wait_for_url timeout from 10s to 30s and add a
health check on the mock-saml service container so it's ready before
tests start.
2026-03-31 21:44:09 -05:00
Stefano Bertelli
a012635dff fix: remove unit tests redundant with e2e, fix test DB isolation
Some checks failed
Dev / test (push) Failing after 7m41s
Dev / docker (push) Has been skipped
Remove 7 test files fully covered by e2e tests (admin, account, models,
API routes, integration MFA/OIDC, notifications). Trim 5 more files to
keep only edge cases not reachable via e2e.

Fix conftest to replace wiregui.db engine/session at import time so all
code uses the test database. Use session-scoped tables with per-test
savepoint isolation to prevent data leaking between tests.
2026-03-31 21:27:46 -05:00
a9f62d5caf fix: add mock client configs and update gitignore
Some checks failed
Dev / test (push) Failing after 2m48s
Dev / docker (push) Has been skipped
2026-03-31 19:23:47 -05:00
ee1d742a71 fix: add victoriametrics container in prod compose
Some checks failed
Dev / test (push) Failing after 2m47s
Dev / docker (push) Has been skipped
2026-03-31 19:17:18 -05:00
71a5f57105 feat: live traffic chart, connection status indicators, 5s refresh
Some checks failed
Dev / test (push) Failing after 2m43s
Dev / docker (push) Has been skipped
- Add ECharts live traffic rate chart on device detail page (RX/s + TX/s
  area lines, 60-point rolling window, human-readable byte axis)
- Add traffic rate display (B/s) next to RX/TX totals
- Add connection status column (green/yellow/red dot) to user and admin
  device tables based on handshake age
- Add status badge to device detail page
- Reduce all UI refresh timers from 30s to 5s
- Add row click navigation on admin devices table
- Allow admins to view any device detail (not just their own)
- Fix rowClick event args (list not dict) on both device tables
- Add connection_status() helper in utils/time.py
2026-03-31 19:12:33 -05:00
c5b66349d6 feat: WireGuard metrics collector + integration test stack
Some checks failed
Dev / test (push) Failing after 2m43s
Dev / docker (push) Has been skipped
Metrics collector (wiregui/collector.py):
- Standalone process spawned by web app when WG_METRICS_ENABLED=true
- Polls wg show dump every WG_METRICS_POLL_INTERVAL seconds (default 5)
- Updates device stats in PostgreSQL
- Pushes Prometheus-format metrics to VictoriaMetrics (if configured)
- Graceful shutdown on SIGTERM

Integration test stack (compose.yml):
- Unified compose file for dev, test, and integration modes
- VictoriaMetrics single-node TSDB for metrics storage
- 3 mock WireGuard client containers generating ping traffic
- Automated setup script seeds server keypair, admin user, client devices
- make test-stack-up: one command to start everything
- make test-stack-verify: validates metrics flowing end-to-end

Infrastructure:
- Makefile with targets for dev, test, integration, and production
- Integration tests verify VictoriaMetrics has data for all 3 clients
- Fix Dockerfile to include img/ directory
- Separate TESTS.md for test tracking, clean TODO.md for features only
2026-03-31 18:30:15 -05:00
70eb9f6b12 fix: run migrations before unit tests in CI
Some checks failed
Dev / test (push) Failing after 2m37s
Dev / docker (push) Has been skipped
Some unit tests (test_api_deps, test_server_key) are integration tests
that need DB tables. Move alembic upgrade head before unit tests.
2026-03-31 17:02:49 -05:00
06b5a3dc12 feat: comprehensive test suite + SAML auth fixes + mock SAML IdP
Some checks failed
Dev / test (push) Failing after 3m14s
Dev / docker (push) Has been skipped
Tests (198 unit + 70 e2e = 268 total):
- Add test_api_deps.py: Bearer token auth, get_current_api_user, require_admin
- Add test_wireguard_extended.py: ensure_interface, set_private_key, set_listen_port
- Add test_firewall_extended.py: _nft/_nft_batch errors, jump rules, policies
- Add test_mfa_login.py: MFA redirect, TOTP verify, invalid code, cancel
- Add test_magic_link_page.py: page render, submit, empty email, back to login
- Add test_admin_devices.py: list, filter, create, edit, delete, config dialog
- Add test_admin_rules.py: list, create, edit, delete (all DB-verified)
- Add test_admin_settings.py: defaults, security, OIDC/SAML providers
- Add test_saml_login.py: button visible, redirect, metadata, full login flow

Bug fixes:
- Fix SAML callback to use /auth/complete bridge (same fix as OIDC)
- Fix missing get_settings import in admin settings page
- Add SAML provider buttons to login page
- Make SAML strict mode configurable per-provider

Infrastructure:
- Add mock SimpleSAMLphp IdP to compose.yml with SP config
- Add mock-saml service to CI workflows (release + dev)
2026-03-31 16:52:29 -05:00
25cff5e4d9 fix: UI tweaks — login layout, nftables code widget, connectivity limit
All checks were successful
Dev / test (push) Successful in 5m1s
Dev / docker (push) Successful in 1m55s
- Put logo and title on same row in login page
- Use ui.code with syntax highlighting for nftables ruleset dialog
- Widen nftables dialog to 900px
- Limit WAN connectivity checks to last 10 entries
2026-03-31 15:50:50 -05:00
0c11cddb53 feat: add logo and logo-inspired color theme
All checks were successful
Dev / test (push) Successful in 4m55s
Dev / docker (push) Successful in 2m9s
- Add transparent SVG logo to img/
- Serve img/ as static files, set SVG favicon
- Show logo on login page and header bar
- Theme Quasar CSS variables using logo palette:
  light: primary #3598C3, secondary #5AA6B9, header navy gradient
  dark: primary #5AA6B9, secondary #3598C3, darker header gradient
2026-03-31 15:43:21 -05:00
f2b04ea668 fix: use branch-based shallow clone in CI to avoid missing SHA
All checks were successful
Dev / test (push) Successful in 5m1s
Dev / docker (push) Successful in 2m1s
Clone with -b GITHUB_REF_NAME instead of depth=1 + checkout SHA,
which fails when the shallow clone doesn't include the target commit.
2026-03-31 15:21:44 -05:00
a06ce9e156 fix: add Playwright, Valkey, and mock-OIDC to CI pipelines
Some checks failed
Dev / test (push) Failing after 46s
Dev / docker (push) Has been skipped
- Add valkey and mock-oidc services to both release and dev workflows
- Install Playwright with Chromium deps for headless e2e tests
- Set WG_REDIS_URL and MOCK_OIDC_HOST env vars for CI
- Make mock OIDC discovery URL configurable via MOCK_OIDC_HOST env var
- Add full test job (unit + e2e) to dev pipeline before Docker build
2026-03-31 14:48:27 -05:00
2163c89b6a feat: fix OIDC auth flow, improve config dialogs, add mock IdP
All checks were successful
Dev / docker (push) Successful in 2m16s
- Fix OIDC callback to extract email from ID token claims as fallback
- Add /auth/complete bridge page to transfer auth to NiceGUI storage
- Use window.location.href for OIDC login (full navigation for OAuth)
- Hide password change card for OIDC-only users
- Widen config dialog, use ui.code with syntax highlighting
- Switch QR codes to PNG base64 images
- Rename logging.py to log_config.py to avoid stdlib shadow
- Add mock-oauth2-server to compose.yml for dev/testing
2026-03-31 14:28:34 -05:00
4d7a4810ff Merge remote-tracking branch 'refs/remotes/origin/dev'
Some checks failed
Dev / docker (push) Has been cancelled
CI / test (push) Failing after 1m52s
CI / release (push) Has been skipped
CI / docker (push) Has been skipped
# Conflicts:
#	TODO.md
2026-03-31 14:26:44 -05:00
3bf6fabcff feat: IdP provisioning from YAML file + Playwright e2e tests
Some checks failed
CI / test (push) Failing after 1m52s
CI / release (push) Has been skipped
CI / docker (push) Has been skipped
Add WG_IDP_CONFIG_FILE env var to seed OIDC/SAML identity providers
from a YAML file at startup, enabling GitOps and IaC workflows.
Providers are upserted by id (merge strategy preserves manual additions).

Convert all e2e tests from NiceGUI User fixture to Playwright async API
with --headed and --slowmo flags for visual debugging. Add full OIDC
login flow test against the mock-oidc service.
2026-03-31 14:23:31 -05:00
Stefano Bertelli
e63f27b8a3 feat: show default values in device create dialog
All checks were successful
Dev / docker (push) Successful in 2m3s
Override fields now display the actual configured defaults (from
DB Settings or env vars) instead of empty placeholders. Fields
are still disabled when the "use default" toggle is on, but users
can see what values their device will get.
2026-03-31 00:21:56 -05:00
Stefano Bertelli
9aa58fbf22 fix: client config uses DB settings instead of only env vars
All checks were successful
Dev / docker (push) Successful in 1m56s
build_client_config was reading defaults (allowed IPs, DNS, endpoint,
MTU, keepalive) from env vars only, ignoring the values set in the
admin Settings page. Now reads from the Configuration DB table first,
falling back to env vars when no DB config exists.
2026-03-31 00:17:29 -05:00
Stefano Bertelli
d3705d224b chore: update TODO with pending items only
All checks were successful
Dev / docker (push) Successful in 1m54s
2026-03-31 00:13:54 -05:00
Stefano Bertelli
f608c542d1 fix: friendlier error when nft lacks permissions
All checks were successful
Dev / docker (push) Successful in 2m12s
2026-03-31 00:04:27 -05:00
Stefano Bertelli
49b2bd9083 feat: firewall policy switches and nftables troubleshooting
All checks were successful
Dev / docker (push) Successful in 2m6s
- Add peer-to-peer and LAN-to-peers switches on the rules page
- Both settings persisted in configurations table and applied
  as nftables chains on toggle
- Add "View nftables Rules" button to dump the live ruleset
  for troubleshooting
- Rules page redesigned with card-based layout matching other
  admin pages
- Rule create/edit/delete events fire as background tasks
2026-03-31 00:00:21 -05:00
Stefano Bertelli
15e1b6360a fix: O(1) IP allocation instead of materializing entire network
All checks were successful
Dev / docker (push) Successful in 1m51s
allocate_ipv4/ipv6 was calling list(network.hosts()) which
materializes 4+ million IP objects for a /10 network, blocking
the event loop for 6+ seconds. Now uses random sampling with
O(1) per attempt — allocates in <1ms on any network size.

This was the root cause of WebSocket disconnects during device
creation in production.
2026-03-30 23:43:59 -05:00
Stefano Bertelli
c9ef58a244 fix: add --no-cache to docker builds to prevent stale images
Some checks failed
CI / test (push) Failing after 2m7s
CI / release (push) Has been skipped
CI / docker (push) Has been skipped
Docker layer caching on the runner was reusing old layers even
when source code changed, resulting in images with outdated code.
2026-03-30 23:36:05 -05:00
Stefano Bertelli
fab5ad29d4 fix: add --no-cache to docker builds to prevent stale images
All checks were successful
Dev / docker (push) Successful in 2m22s
Docker layer caching on the runner was reusing old layers even
when source code changed, resulting in images with outdated code.
2026-03-30 23:35:44 -05:00
Stefano Bertelli
1c9de39079 chore: add dev branch pipeline for pre-release images
All checks were successful
Dev / docker (push) Successful in 7s
Builds and pushes docker images on every push to dev branch.
Tags based on latest main release: e.g. v1.2.3.dev0, v1.2.3.dev5.
No tests — fast feedback loop for testing.
2026-03-30 23:32:01 -05:00
Stefano Bertelli
a8784eec9c fix: show config dialog immediately, run WG/firewall setup in background
All checks were successful
CI / test (push) Successful in 2m5s
CI / release (push) Successful in 35s
CI / docker (push) Successful in 55s
In production (WG_WG_ENABLED=true), on_device_created() runs multiple
WG and nftables subprocess calls that take seconds. The UI handler
was awaiting all of them before showing the config dialog, causing
WebSocket timeouts and page reloads.

Now the dialog/QR/download appears right after DB commit, and WG peer
+ firewall configuration runs as a background task via asyncio.create_task.
2026-03-30 23:24:51 -05:00
Stefano Bertelli
44c20cb66b fix: white background for QR codes in dark mode
All checks were successful
CI / test (push) Successful in 2m3s
CI / release (push) Successful in 35s
CI / docker (push) Successful in 55s
2026-03-30 23:14:57 -05:00
Stefano Bertelli
41a62832f7 fix: pure Python keypair generation, no wg CLI dependency
Some checks failed
CI / test (push) Successful in 2m5s
CI / release (push) Successful in 34s
CI / docker (push) Has been cancelled
Replace subprocess calls to wg genkey/pubkey with cryptography
library's X25519PrivateKey. This eliminates the wg CLI dependency
for key generation, fixes device creation on machines without
wireguard-tools, and removes the event loop blocking that caused
WebSocket disconnects during device creation.

Also fix E2E test teardown to use a fresh engine for cleanup,
avoiding cross-event-loop issues with asyncpg connection pools.
2026-03-30 23:11:58 -05:00