Merge NAPALM/napalm-device-types main (4.50.0) into feature/host-logins
driver / lint (pull_request) Successful in 17s
driver / standard (pull_request) Successful in 21s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m19s
driver / test (3.12) (pull_request) Successful in 1m26s
driver / lowest (pull_request) Successful in 47s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Failing after 1m5s
CI / driver (pull_request) Failing after 2m45s
driver / publish (pull_request) Skipped

v4.50.0 went to #140, so this branch's release is 4.51.0 now.
This commit is contained in:
christianmanivong committed 2026-11-28 08:22:46 +01:00
commit 4b4797e383
7 files changed
+164 -3

No files matched your search

+10
View File
@@ -236,6 +236,12 @@ from napalm_device_types.login_accounts import (
login_capable,
parse_login_accounts,
)
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
@@ -672,6 +678,10 @@ __all__ = [
"parse_system_identity",
"OpenSshServerMixin",
"PamAuthEntryDict",
"LOGIN_FACTORS",
"LoginFactors",
"LoginSourceDict",
"WebLoginAuthDict",
"SshServerAuthDict",
"SshServerAuthMixin",
"SSHD_EFFECTIVE_COMMAND",
+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]
+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