Compare commits

...
5 Commits
Author SHA1 Message Date
christianmanivong 917e9e570d Merge pull request 'feat(login-sources): where a device checks a login, and what each place asks for, 4.50.0 (NetOrk/netork#662)' (#140) from feature/web-login-auth into main
driver / types (push) Successful in 57s
driver / standard (push) Successful in 18s
driver / lint (push) Successful in 16s
driver / test (3.12) (push) Successful in 1m19s
driver / test (3.13) (push) Successful in 1m11s
driver / lowest (push) Successful in 46s
driver / build (push) Successful in 32s
driver / security (push) Successful in 59s
driver / publish (push) Successful in 30s
CI / driver (push) Successful in 3m39s
2026-11-28 07:06:53 +00:00
christianmanivong d778c805c1 feat(login-sources): where a device checks a login, and what each place asks for, 4.50.0 (NetOrk/netork#662)
driver / standard (pull_request) Successful in 20s
driver / lint (pull_request) Successful in 17s
driver / types (pull_request) Successful in 1m1s
driver / test (3.12) (pull_request) Successful in 1m22s
driver / test (3.13) (pull_request) Successful in 1m13s
driver / lowest (pull_request) Successful in 43s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m0s
CI / driver (pull_request) Successful in 3m0s
driver / publish (pull_request) Skipped
LoginSourceDict names one source with the device's word for its kind and what
it asks for: password, password_otp, external or unknown. WebLoginAuthDict is
what a driver's get_web_login_auth returns, every source the web interface
tries, in the device's order. SshServerAuthDict takes password_sources and
server_enabled for a platform that writes sshd_config itself.
2026-11-28 08:02:12 +01:00
christianmanivong 07920941c8 Merge pull request 'feat(access-point): a radio's runtime state beside its configuration, 4.49.0 (NetOrk/netork#31)' (#137) from feature/radio-runtime-state into main
driver / standard (push) Successful in 16s
driver / lint (push) Successful in 14s
driver / types (push) Successful in 1m0s
driver / test (3.12) (push) Successful in 1m15s
driver / test (3.13) (push) Successful in 1m11s
driver / lowest (push) Successful in 42s
driver / build (push) Successful in 32s
driver / security (push) Successful in 1m15s
driver / publish (push) Successful in 29s
CI / driver (push) Successful in 4m29s
2026-11-28 02:07:50 +00:00
christianmanivong 92b1b6402b chore(release): 4.49.0
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 18s
driver / types (pull_request) Successful in 1m2s
driver / lowest (pull_request) Successful in 51s
driver / test (3.12) (pull_request) Successful in 1m39s
driver / test (3.13) (pull_request) Successful in 1m36s
driver / build (pull_request) Successful in 38s
driver / security (pull_request) Successful in 1m11s
CI / driver (pull_request) Successful in 3m5s
driver / publish (pull_request) Skipped
2026-11-28 03:02:13 +01:00
christianmanivong e4fde2283a feat(access-point): a radio's runtime state beside its configuration (NetOrk/netork#31)
RadioStatusDict carries up, pending and setup_failed, each optional: a
driver that cannot read the state leaves them out. A radio can be enabled
and not run, as on 2026-07-16, when a rejected value kept every radio of
a fleet in a restart loop the configuration never showed.

The access point shapes move to access_point_models.py for the file size
ratchet; models re-exports each where it was.
2026-11-28 03:02:13 +01:00
11 changed files with 331 additions and 99 deletions

No files matched your search

+25
View File
@@ -7,6 +7,31 @@ recorded here; their history is the git log.
## [Unreleased]
## [4.50.0] - 2026-11-28
### Added
- `login_sources`: where a device checks a person's login, and what each place asks for
(NetOrk/netork#662). `LoginSourceDict` names one source with the device's own word for its
kind and what it asks for (`LoginFactors`: `password`, `password_otp`, `external`,
`unknown`; all four in `LOGIN_FACTORS`). `WebLoginAuthDict` is the reading a driver returns
from `get_web_login_auth`: every source the web interface tries, in the device's order.
There is no mixin, so `hasattr(driver, "get_web_login_auth")` stays a truthful answer.
- `SshServerAuthDict` takes two optional keys for a platform that writes sshd_config itself
and is read from its own configuration. `password_sources` says what checks a password or
keyboard-interactive login where the platform decides that rather than PAM's stack.
`server_enabled` is False when the platform's SSH server is switched off. Readings from
`sshd -T` leave both out.
## [4.49.0] - 2026-11-28
### Added
- `RadioStatusDict` carries a radio's runtime state beside its configuration
(NetOrk/netork#31): `up` (the radio runs), `pending` (the device is still bringing it
up or down) and `setup_failed` (the device gave up bringing it up after its retries).
All three are optional: a driver that cannot read the state leaves them out. A radio
can be `enabled` and not run, as on 2026-07-16, when a rejected value kept every radio
of a fleet in a restart loop the configuration never showed.
## [4.48.0] - 2026-11-27
### Added
+9
View File
@@ -354,6 +354,15 @@ login user and followed through `@include`, `include` and `substack`. Which of t
second factor is the consumer's call. `Match` blocks are not read. `OpenSshServerMixin`
carries it; a driver can also mix it in alone and supply `run_command`.
`login_sources` describes where a device checks a person's login, for platforms that try a
login against a list of authentication servers and let in whatever the first one accepts
(OPNsense). A driver that can read its web interface's list implements
`get_web_login_auth() -> WebLoginAuthDict`: each source with its name, the device's word for
its kind, and what it asks for (`password`, `password_otp`, `external` or `unknown`). Such a
platform's `get_ssh_server_auth` may add `password_sources` (what checks an SSH password)
and `server_enabled` (False when SSH is off) to `SshServerAuthDict`. Which source counts as
a second factor is the consumer's call.
`SudoHistoryMixin` (`get_history_sudo_lines`, `remove_history_sudo_lines`) deals with what
a driver left behind when it typed `echo '<password>' | sudo -S -p "" …` into an interactive
shell: that line, password and all, in the login user's shell history, and files its partial
+10
View File
@@ -227,6 +227,12 @@ from napalm_device_types.log_sources import (
parse_log_forwarding,
parse_log_sources,
)
from napalm_device_types.login_sources import (
LOGIN_FACTORS,
LoginFactors,
LoginSourceDict,
WebLoginAuthDict,
)
from napalm_device_types.mac_acl import MacAclMixin
from napalm_device_types.management_controller import ManagementControllerDriver
from napalm_device_types.media import MediaDriver
@@ -657,6 +663,10 @@ __all__ = [
"parse_system_identity",
"OpenSshServerMixin",
"PamAuthEntryDict",
"LOGIN_FACTORS",
"LoginFactors",
"LoginSourceDict",
"WebLoginAuthDict",
"SshServerAuthDict",
"SshServerAuthMixin",
"SSHD_EFFECTIVE_COMMAND",
+115
View File
@@ -0,0 +1,115 @@
"""The shapes an access point's getters return (models.py's Access Point part).
Apart from ``models.py`` for its size; ``models`` re-exports each, so
``napalm_device_types.models.RadioStatusDict`` stays where callers import it.
"""
from typing import NotRequired
from typing_extensions import TypedDict
class WirelessClientDict(TypedDict):
mac: str
ssid: str
radio: str
signal: int
noise: int
tx_rate: float
rx_rate: float
uptime: int
# Optional fields populated by DHCP cross-reference (e.g. from firewall)
ip: NotRequired[str]
hostname: NotRequired[str]
lease_end: NotRequired[int] # Unix timestamp when DHCP lease expires
class SSIDDict(TypedDict):
enabled: bool
radio: str
bssid: str
encryption: str
hidden: bool
clients: int
class RadioStatusDict(TypedDict):
"""One radio: ``enabled`` is the configuration, the rest what the radio does.
The runtime state is left out where the driver cannot read it, never guessed
(NetOrk/netork#31): ``up`` whether the radio runs, ``pending`` whether the
device is still bringing it up or down, ``setup_failed`` whether the device
gave up bringing it up after its retries.
"""
enabled: bool
band: str
channel: int
channel_width: int
tx_power: int
frequency: float
up: NotRequired[bool]
pending: NotRequired[bool]
setup_failed: NotRequired[bool]
class ChannelScanEntryDict(TypedDict):
"""One neighboring AP entry as returned by get_channel_scan()."""
bssid: str
ssid: str
frequency: int # centre frequency in MHz, e.g. 2437
channel: int # channel number, e.g. 6
signal_dbm: int # RSSI in dBm, e.g. -72
channel_width: int # MHz: 20 / 40 / 80 / 160; 0 if unknown
band: str # "2.4GHz" | "5GHz" | "6GHz"
class WirelessConfigDict(TypedDict):
country_code: str
regulatory_domain: str
beacon_interval: int
dtim_period: int
rts_threshold: int
fragmentation_threshold: int
short_preamble: bool
wmm_enabled: bool
class FastTransitionConfigDict(TypedDict):
enabled: bool
ssid: str
mobility_domain: str
reassociation_deadline: int
r0_key_lifetime: int
r1_key_holder: str
pmk_r1_push: bool
over_ds: bool
class MeshPeerDict(TypedDict):
mac: str
radio: str
signal: int
tx_rate: float
rx_rate: float
uptime: int
hop_count: int
class MeshConfigDict(TypedDict):
enabled: bool
radio: str
mesh_id: str
path_metric: str
gate_announcements: bool
is_gate: bool
encryption: str
class SSIDBridgeDict(TypedDict):
ssid: str
bridge: str
vlan_id: int
tagged: bool
client_isolation: bool
+59
View File
@@ -0,0 +1,59 @@
"""Where a device checks a person's login, and what each place asks for.
Some platforms keep their own list of authentication servers and try a login
against each in turn, and the first one that accepts it lets the person in. On
OPNsense that list (*System → Settings → Administration → Authentication*) serves
the web interface, the console and sshd's password login alike. Whether a password
alone gets in then depends on every server in the list, not on one switch. So the
driver names each place it tries, in the device's own order, with what that place
asks for. Which of them counts as a second factor for a policy is the consumer's
call (NetOrk/netork#662).
Two readings carry these sources:
- ``get_web_login_auth`` returns :class:`WebLoginAuthDict`: how the device's web
interface lets people log in. A driver that cannot tell does not have the method,
so ``hasattr`` stays a truthful answer.
- :class:`~napalm_device_types.ssh_server_auth.SshServerAuthDict` takes
``password_sources`` where the platform, not PAM's stack, decides what checks a
password over SSH.
What a source asks for (:data:`LOGIN_FACTORS`):
- ``password``: a password alone, as with local accounts or an LDAP bind.
- ``password_otp``: a password and a one-time code together. Without a code
there is no login.
- ``external``: another system decides, for example a RADIUS server. How many
factors it asks for cannot be seen from the device.
- ``unknown``: a kind of source the driver does not know.
"""
from __future__ import annotations
from typing import Literal, TypedDict
LoginFactors = Literal["password", "password_otp", "external", "unknown"]
#: Every value of :data:`LoginFactors`, in the order of the module docstring.
LOGIN_FACTORS: tuple[LoginFactors, ...] = ("password", "password_otp", "external", "unknown")
class LoginSourceDict(TypedDict):
"""One place a login is checked.
``{"name": "TOTP", "kind": "totp", "factors": "password_otp"}``
"""
#: The source's name as the device shows it.
name: str
#: The device's own word for the kind, as written: ``local``, ``totp``, ``radius``.
kind: str
factors: LoginFactors
class WebLoginAuthDict(TypedDict):
"""How a device's web interface lets people log in, as ``get_web_login_auth`` read it."""
#: Every source a login is tried against, in the device's order. A login that
#: any one of them accepts gets in.
sources: list[LoginSourceDict]
+13 -96
View File
@@ -8,7 +8,19 @@ from typing import Literal, NotRequired, get_args
from typing_extensions import TypedDict
# The SNMP health profile shapes live in snmp_health_profile.py; re-exported here, where they were.
# The SNMP health profile shapes live in snmp_health_profile.py, those of the access
# point getters in access_point_models.py; re-exported here, where they were.
from napalm_device_types.access_point_models import ChannelScanEntryDict as ChannelScanEntryDict
from napalm_device_types.access_point_models import (
FastTransitionConfigDict as FastTransitionConfigDict,
)
from napalm_device_types.access_point_models import MeshConfigDict as MeshConfigDict
from napalm_device_types.access_point_models import MeshPeerDict as MeshPeerDict
from napalm_device_types.access_point_models import RadioStatusDict as RadioStatusDict
from napalm_device_types.access_point_models import SSIDBridgeDict as SSIDBridgeDict
from napalm_device_types.access_point_models import SSIDDict as SSIDDict
from napalm_device_types.access_point_models import WirelessClientDict as WirelessClientDict
from napalm_device_types.access_point_models import WirelessConfigDict as WirelessConfigDict
from napalm_device_types.snmp_health_profile import SnmpHealthProfile as SnmpHealthProfile
from napalm_device_types.snmp_health_profile import SnmpInterfacesSpec as SnmpInterfacesSpec
from napalm_device_types.snmp_health_profile import SnmpMemorySpec as SnmpMemorySpec
@@ -130,101 +142,6 @@ class HostStatusDict(TypedDict):
# ---------------------------------------------------------------------------
class WirelessClientDict(TypedDict):
mac: str
ssid: str
radio: str
signal: int
noise: int
tx_rate: float
rx_rate: float
uptime: int
# Optional fields populated by DHCP cross-reference (e.g. from firewall)
ip: NotRequired[str]
hostname: NotRequired[str]
lease_end: NotRequired[int] # Unix timestamp when DHCP lease expires
class SSIDDict(TypedDict):
enabled: bool
radio: str
bssid: str
encryption: str
hidden: bool
clients: int
class RadioStatusDict(TypedDict):
enabled: bool
band: str
channel: int
channel_width: int
tx_power: int
frequency: float
class ChannelScanEntryDict(TypedDict):
"""One neighboring AP entry as returned by get_channel_scan()."""
bssid: str
ssid: str
frequency: int # centre frequency in MHz, e.g. 2437
channel: int # channel number, e.g. 6
signal_dbm: int # RSSI in dBm, e.g. -72
channel_width: int # MHz: 20 / 40 / 80 / 160; 0 if unknown
band: str # "2.4GHz" | "5GHz" | "6GHz"
class WirelessConfigDict(TypedDict):
country_code: str
regulatory_domain: str
beacon_interval: int
dtim_period: int
rts_threshold: int
fragmentation_threshold: int
short_preamble: bool
wmm_enabled: bool
class FastTransitionConfigDict(TypedDict):
enabled: bool
ssid: str
mobility_domain: str
reassociation_deadline: int
r0_key_lifetime: int
r1_key_holder: str
pmk_r1_push: bool
over_ds: bool
class MeshPeerDict(TypedDict):
mac: str
radio: str
signal: int
tx_rate: float
rx_rate: float
uptime: int
hop_count: int
class MeshConfigDict(TypedDict):
enabled: bool
radio: str
mesh_id: str
path_metric: str
gate_announcements: bool
is_gate: bool
encryption: str
class SSIDBridgeDict(TypedDict):
ssid: str
bridge: str
vlan_id: int
tagged: bool
client_isolation: bool
class Dot1XConfigDict(TypedDict):
"""802.1X / WPA-Enterprise config for an access-point SSID."""
+24 -1
View File
@@ -30,6 +30,8 @@ import re
from collections.abc import Mapping
from typing import TYPE_CHECKING, TypedDict
from napalm_device_types.login_sources import LoginSourceDict
if TYPE_CHECKING: # pragma: no cover - for type checkers only
from napalm_device_types.channel import CommandResult
@@ -62,7 +64,18 @@ class PamAuthEntryDict(TypedDict):
args: list[str]
class SshServerAuthDict(TypedDict):
class _PlatformSshAuthDict(TypedDict, total=False):
"""The keys of :class:`SshServerAuthDict` only a platform that writes sshd_config sets.
A base of their own, as ``total=False``: ``NotRequired`` under postponed
annotations is not seen by the class at runtime.
"""
password_sources: list[LoginSourceDict]
server_enabled: bool
class SshServerAuthDict(_PlatformSshAuthDict):
"""How an OpenSSH server lets people log in, as ``get_ssh_server_auth`` read it.
The global settings ``sshd -T`` prints. A ``Match`` block can change them for
@@ -77,6 +90,16 @@ class SshServerAuthDict(TypedDict):
``use_pam`` is None where sshd has no PAM (OpenBSD). ``pam_auth_stack`` is the
``auth`` stack PAM runs for sshd, includes and substacks followed; None when
PAM is off or its files gave nothing for sshd.
Two keys only a platform that writes sshd_config itself sets, read from its
own configuration rather than from a running sshd:
- ``password_sources``: what checks a password or keyboard-interactive login,
where the platform decides that rather than PAM's stack. OPNsense's PAM
module tries its authentication servers. Absent where the stack says it.
- ``server_enabled``: False when the platform's SSH server is switched off.
Nobody then logs in over SSH, whatever the other keys say. Absent where the
reading came from a running sshd.
"""
password_authentication: bool
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "napalm-device-types"
version = "4.48.0"
version = "4.50.0"
description = "Abstract device-type base classes for NAPALM drivers"
readme = "README.md"
requires-python = ">=3.12"
+1 -1
View File
@@ -31,7 +31,7 @@
},
"mypy_relaxed": [],
"python_file_lines": {
"napalm_device_types/models.py": 1436
"napalm_device_types/models.py": 1353
},
"untyped_public": []
}
+45
View File
@@ -0,0 +1,45 @@
"""Where a device checks a login, and what each place asks for (NetOrk/netork#662).
The module is a contract, not a reader: the shapes a driver returns from
``get_web_login_auth`` and, where its platform says it, in ``get_ssh_server_auth``.
These tests pin the vocabulary consumers match on.
"""
from __future__ import annotations
from typing import get_args, get_type_hints
import napalm_device_types
from napalm_device_types.login_sources import (
LOGIN_FACTORS,
LoginFactors,
LoginSourceDict,
WebLoginAuthDict,
)
from napalm_device_types.ssh_server_auth import SshServerAuthDict
def test_the_factor_names_are_the_literal_s():
assert LOGIN_FACTORS == get_args(LoginFactors)
assert LOGIN_FACTORS == ("password", "password_otp", "external", "unknown")
def test_a_source_names_itself_its_kind_and_what_it_asks_for():
assert set(get_type_hints(LoginSourceDict)) == {"name", "kind", "factors"}
def test_a_web_reading_is_its_sources_in_the_device_s_order():
assert set(get_type_hints(WebLoginAuthDict)) == {"sources"}
def test_an_ssh_reading_may_say_where_a_password_is_checked_and_that_sshd_is_off():
optional = SshServerAuthDict.__optional_keys__
assert {"password_sources", "server_enabled"} <= optional
# The keys every OpenSSH reading carries stay required.
assert "password_authentication" in SshServerAuthDict.__required_keys__
def test_the_package_exports_the_shapes():
for name in ("LOGIN_FACTORS", "LoginFactors", "LoginSourceDict", "WebLoginAuthDict"):
assert name in napalm_device_types.__all__
assert hasattr(napalm_device_types, name)
+29
View File
@@ -0,0 +1,29 @@
"""A radio's runtime state beside its configuration (NetOrk/netork#31).
A radio can be enabled in the configuration and still not run: the 2026-07-16
incident put every radio of a fleet into a restart loop that the configuration
never showed. The state the device reports is three facts, each optional,
because a driver that cannot read it leaves it out rather than guessing.
"""
from __future__ import annotations
from typing import get_type_hints
from napalm_device_types.models import RadioStatusDict
RUNTIME = {"up", "pending", "setup_failed"}
def test_a_radio_may_say_whether_it_runs():
hints = get_type_hints(RadioStatusDict)
assert RUNTIME <= set(hints)
assert all(hints[key] is bool for key in RUNTIME)
def test_the_runtime_state_is_optional():
assert RUNTIME <= RadioStatusDict.__optional_keys__
def test_the_configured_fields_stay_required():
assert {"enabled", "band", "channel"} <= RadioStatusDict.__required_keys__