feat(login): get_web_login_auth on PVE and PBS, 0.20.0 (NetOrk/netork#662) #82

Open
christianmanivong wants to merge 2 commits from feature/web-login-auth-662 into main
pull from: feature/web-login-auth-662
Owner

Part of NetOrk/netork#662 (NIS2 Art. 21(2)(j): MFA on the managed systems). The OPNsense step was NetOrk/netork#2827; this is the reader for Proxmox VE and PBS.

What it adds

get_web_login_auth() on both drivers, in napalm-device-types' WebLoginAuthDict (4.50.0):

  • One source per realm with someone who can log in, by realm name (name = realm, kind = realm type).
  • password_otp when the PVE realm's own tfa is set (oath/yubico; PVE then refuses a user without a second factor, "missing required 2nd keys"), or when every enabled, unexpired user of the realm has an enabled second factor in /access/tfa (TOTP, WebAuthn, U2F, Yubico, recovery keys).
  • password when one such user has none -- often root@pam.
  • external for OpenID (its provider decides), unknown for a realm type the driver does not know.
  • Disabled or expired accounts do not count; a password realm without anyone who can log in is no source. API tokens skip TFA by design and are not web logins.

Privilege check

Neither server refuses /access/users or /access/tfa to a login that may not see other users: both answer with the caller alone. A reading from such a token would judge the server by one account and could pass. So the driver checks /access/permissions first and raises PermissionError without:

  • PVE: Sys.Audit or User.Modify on /access/groups (PVEAuditor on / has it),
  • PBS: Sys.Audit on /access/users (Audit on / has it).

Also

  • Version 0.20.0 (0.19.0 is #81), needs napalm-device-types >= 4.50.0.
  • tests/pbs_fake.py: the fake's path argument is positional-only, so a query parameter named path (/access/permissions?path=...) reaches the fake as proxmoxer passes it.
  • Tests: tests/test_web_login.py, answers shaped after the API schema of pve-access-control and proxmox-backup; full suite 797 passed locally, ruff and mypy clean.
Part of NetOrk/netork#662 (NIS2 Art. 21(2)(j): MFA on the managed systems). The OPNsense step was NetOrk/netork#2827; this is the reader for Proxmox VE and PBS. ## What it adds `get_web_login_auth()` on both drivers, in napalm-device-types' `WebLoginAuthDict` (4.50.0): - One source per realm with someone who can log in, by realm name (`name` = realm, `kind` = realm type). - `password_otp` when the PVE realm's own `tfa` is set (`oath`/`yubico`; PVE then refuses a user without a second factor, "missing required 2nd keys"), or when every enabled, unexpired user of the realm has an enabled second factor in `/access/tfa` (TOTP, WebAuthn, U2F, Yubico, recovery keys). - `password` when one such user has none -- often `root@pam`. - `external` for OpenID (its provider decides), `unknown` for a realm type the driver does not know. - Disabled or expired accounts do not count; a password realm without anyone who can log in is no source. API tokens skip TFA by design and are not web logins. ## Privilege check Neither server refuses `/access/users` or `/access/tfa` to a login that may not see other users: both answer with the caller alone. A reading from such a token would judge the server by one account and could pass. So the driver checks `/access/permissions` first and raises `PermissionError` without: - PVE: `Sys.Audit` or `User.Modify` on `/access/groups` (`PVEAuditor` on `/` has it), - PBS: `Sys.Audit` on `/access/users` (`Audit` on `/` has it). ## Also - Version 0.20.0 (0.19.0 is #81), needs napalm-device-types >= 4.50.0. - `tests/pbs_fake.py`: the fake's `path` argument is positional-only, so a query parameter named `path` (`/access/permissions?path=...`) reaches the fake as proxmoxer passes it. - Tests: `tests/test_web_login.py`, answers shaped after the API schema of pve-access-control and proxmox-backup; full suite 797 passed locally, ruff and mypy clean.
christianmanivong added 1 commit 2026-11-28 23:20:11 +00:00
feat(login): get_web_login_auth on PVE and PBS, a source per realm, 0.20.0 (NetOrk/netork#662)
driver / standard (pull_request) Failing after 17s
driver / lint (pull_request) Successful in 18s
driver / types (pull_request) Successful in 56s
driver / lowest (pull_request) Successful in 37s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / security (pull_request) Successful in 53s
driver / build (pull_request) Successful in 49s
CI / driver (pull_request) Failing after 2m8s
driver / publish (pull_request) Skipped
f554e2cc79
A Proxmox login names its realm, so each realm with someone who can log in
is a source of napalm-device-types' WebLoginAuthDict. It asks for a password
and a one-time code when the PVE realm's own tfa is set, or when every
enabled, unexpired user of it has an enabled second factor (/access/tfa);
a password alone when one user has none; OpenID is external.

Both servers list only the caller in /access/users and /access/tfa when the
login may not see the others, so the driver checks /access/permissions
first: Sys.Audit or User.Modify on /access/groups on PVE, Sys.Audit on
/access/users on PBS. Without it the read raises PermissionError rather
than judge the server by one account.

Needs napalm-device-types 4.50.0.
christianmanivong added 1 commit 2026-11-28 23:29:55 +00:00
docs(login): an account that only holds API tokens counts as a login (NetOrk/netork#662)
driver / lint (pull_request) Successful in 13s
driver / standard (pull_request) Failing after 16s
driver / lowest (pull_request) Successful in 34s
driver / types (pull_request) Successful in 1m0s
driver / test (3.12) (pull_request) Successful in 1m13s
driver / test (3.13) (pull_request) Successful in 1m5s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 58s
CI / driver (pull_request) Failing after 1m48s
driver / publish (pull_request) Skipped
93ba43071b
The API says whether a user has a second factor, not whether it has a
password; a second factor on such an account leaves its tokens alone.
Some required checks failed
driver / lint (pull_request) Successful in 13s
driver / standard (pull_request) Failing after 16s
driver / lowest (pull_request) Successful in 34s
driver / types (pull_request) Successful in 1m0s
driver / test (3.12) (pull_request) Successful in 1m13s
driver / test (3.13) (pull_request) Successful in 1m5s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 58s
CI / driver (pull_request) Failing after 1m48s
driver / publish (pull_request) Skipped
This pull request has changes conflicting with the target branch.
  • CHANGELOG.md
  • README.md
  • pyproject.toml
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/web-login-auth-662:feature/web-login-auth-662
git checkout feature/web-login-auth-662
Sign in to join this conversation.