feat(accounts): add_service_account takes the keys the new one replaces #115

Merged
christianmanivong merged 3 commits from fix/service-account-replaces into main 2026-11-13 08:55:09 +00:00
Owner

What and why

netOrk moves its own account on a host from its installation-wide key to the key of the host's site (NetOrk/netork#2462: one system key per site, so a satellite holds a login for its own site's hosts only). The old key then has to come off the account. remove_local_account_keys cannot do that: it refuses the login user's own account and system accounts (uid < 1000), and netOrk's account is both.

Change

add_service_account(name, public_key, *, uid=None, replaces=()): the keys in replaces go from the account once public_key is in it, as a step old keys, matched by their base64 as in add_local_account. public_key itself never goes, and while it could not be added the old keys stay, so netOrk keeps its way in. netOrk calls it through a login with the new key, after trying that login.

Tests

tests/test_service_account.py: a replaced key goes once the new one is in; the new key is never one that goes; a replaced key stays while the new one could not be added; replaces must be a list, not one string. The full suite passes (1641 passed, 3 skipped); ruff and mypy are clean.

CHANGELOG: under Unreleased. NetOrk/netork pins this branch's commit (6795847) in the PR for #2462. A merge commit keeps that SHA reachable.

## What and why netOrk moves its own account on a host from its installation-wide key to the key of the host's site (NetOrk/netork#2462: one system key per site, so a satellite holds a login for its own site's hosts only). The old key then has to come off the account. `remove_local_account_keys` cannot do that: it refuses the login user's own account and system accounts (uid < 1000), and netOrk's account is both. ## Change `add_service_account(name, public_key, *, uid=None, replaces=())`: the keys in `replaces` go from the account once `public_key` is in it, as a step `old keys`, matched by their base64 as in `add_local_account`. `public_key` itself never goes, and while it could not be added the old keys stay, so netOrk keeps its way in. netOrk calls it through a login with the new key, after trying that login. ## Tests `tests/test_service_account.py`: a replaced key goes once the new one is in; the new key is never one that goes; a replaced key stays while the new one could not be added; `replaces` must be a list, not one string. The full suite passes (1641 passed, 3 skipped); ruff and mypy are clean. CHANGELOG: under Unreleased. NetOrk/netork pins this branch's commit (6795847) in the PR for #2462. A merge commit keeps that SHA reachable.
christianmanivong added 1 commit 2026-11-12 21:25:28 +00:00
feat(accounts): add_service_account takes the keys the new one replaces
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Failing after 18s
driver / types (pull_request) Successful in 1m1s
driver / test (3.13) (pull_request) Successful in 1m11s
driver / test (3.12) (pull_request) Successful in 1m19s
driver / lowest (pull_request) Successful in 46s
driver / build (pull_request) Successful in 38s
driver / security (pull_request) Successful in 1m16s
CI / driver (pull_request) Failing after 2m45s
driver / publish (pull_request) Skipped
679584766f
netOrk moves a host from its installation-wide key to its site's
(NetOrk/netork#2462): the old key has to go from its own account, which
remove_local_account_keys refuses (the login's own account, a system
account). With replaces, the old keys go once the new key is in -- never
the new key itself, and not while it could not be added.
christianmanivong added 2 commits 2026-11-13 08:00:44 +00:00
refactor(accounts): the account step of add_service_account in a helper
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 52s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / lowest (pull_request) Successful in 39s
driver / test (3.13) (pull_request) Successful in 1m7s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 54s
CI / driver (pull_request) Successful in 2m32s
driver / publish (pull_request) Skipped
4c0ba5b2c0
replaces= made add_service_account 55 lines long, over the quality
ratchet's 50. Its account step -- none to take when the driver logs in
as the account already, else the create or reopen -- moves to
_accounts_service_account_step. Behaviour is unchanged; the tests of
add_service_account cover both branches.
christianmanivong merged commit 241acef6c1 into main 2026-11-13 08:55:09 +00:00
christianmanivong deleted branch fix/service-account-replaces 2026-11-13 08:55:09 +00:00
Sign in to join this conversation.