Feature request: let auth plugins act as a primary authenticator (passwordless login)
This is not a request to add WebAuthn to luci-base. #8273 was closed because passkeys in core would drag in TLS/CA/mDNS/hostname requirements, and I agree with that reasoning. This asks for something smaller: that the plugin mechanism merged in #8281 be able to authenticate a user instead of a password, so the crypto stays entirely in out-of-tree addons.
The gap
auth/login/ plugins are second factors by construction. check() runs after
password verification and verify() can only approve or reject a login that already
succeeded. A plugin cannot establish who the user is.
The blocker is session creation rather than the hook itself. session_setup() in
dispatcher.uc calls ubus session.login, which requires a password. rpcd then calls
rpc_login_setup_acls(), which globs /usr/share/rpcd/acl.d/*.json and expands the
user's login section into session ACLs. That expansion exists only inside rpcd's
login handler — there is no ubus method meaning "grant this session the ACLs user X
would receive".
This is already causing harm out of tree
Projects needing passwordless login reimplement rpcd's ACL assignment themselves:
- luci-sso (OIDC) has
create_passwordless_session(), which callssession.create, scans/usr/share/rpcd/acl.ditself, and grants groups — including a wildcard path that grantsubus:*:*,uci:*:*andfile:*:*. - luci-app-webauthn cannot offer passwordless login at all.
Security-critical ACL logic is being duplicated in ucode, once per project, because there is no supported primitive. One correct implementation seems better than N approximate ones.
Proposed shape
rpcd — a privileged session-setup method reusing code already present:
ubus call session setup '{ "username": "root", "timeout": 3600 }'It performs the rpc_login_setup_acls() half of rpc_handle_login() and skips
rpc_login_test_login(). No new ACL logic: the existing expansion is reused verbatim,
and rpcd remains the single authority on what a user may do.
Because this mints authority from nothing, reachability matters more than the method body. Two layers apply, and I checked both on a running system:
- On the local socket,
ubusd_acl_check()returns allow whenever!cl->uid, so any root-owned process is unrestricted, while non-root callers are default-denied against/usr/share/acl.d(the built-in default forubusd_acl_dir). The intended caller — the LuCI dispatcher — is root, so "root only" is not by itself a meaningful boundary. - Over
/ubusthe bridge callssession.accessbefore forwarding, so reachability is exactly what acl.d grants. On a stock system the null session is grantedubus:session:loginby/usr/share/rpcd/acl.d/unauthenticated.json, and a hypotheticalsetupis denied:
# SID=00000000000000000000000000000000
# ubus call session access "{\"ubus_rpc_session\":\"$SID\",\"scope\":\"ubus\",
# \"object\":\"session\",\"function\":\"login\"}"
{ "access": true }
# ... the same call with "function":"setup"
{ "access": false }So such a method is default-denied to HTTP callers as things stand, and the shipped
unauthenticated grant lists individual functions rather than a wildcard. The residual
concern is that this is default-deny by omission: an acl.d file granting the session
object with a wildcard function would expose it, and unlike session.login there is no
password behind it to fail closed on.
luci-base — extend the plugin object from #8281 with two optional methods alongside the existing pair.
check(http, user) -> existing, second factor
verify(http, user) -> existing, second factor
begin(http) -> new: { available, html, assets, message }
identify(http) -> new: { authenticated, username, message }load() today hard-requires check and verify to be functions; it would instead
accept a plugin exposing either pair. begin() renders the login-page affordance
through the existing html/assets path. On a POST carrying the plugin's field but no
password, the dispatcher calls identify() and, on success, creates the session for the
returned username. values.username and values.token are set exactly as
session_setup() does today, so session_retrieve() is unchanged.
identify() is honoured only when the plugin declares primary: true and uci opts in —
luci_plugins.<uuid>.primary, plus a global auth_primary_enabled mirroring the
existing auth_login_enabled. That keeps "what on this system can mint a session for an
arbitrary user?" an explicit config query.
Safety properties
Addressing @systemcrash's point in #8273 that any security feature must have a recourse:
- The password form always renders. A primary plugin is additive and can never remove or replace it, so ordinary login remains the recourse, alongside ssh and failsafe.
- The username a plugin returns is validated against the
loginsections in/etc/config/rpcd. A plugin cannot mint a session for a user with no LuCI login. - Second-factor plugins still run after a primary authentication, so passkey-primary composes with TOTP-second-factor.
- The rate limiting already in
authplugins.ucis reused. LOG_AUTHPRIVon success and failure, matchingsession_setup().- luci-base gains no crypto, no new dependency, and no knowledge of WebAuthn or OIDC.
Before writing code
I would rather agree the shape than send a PR that gets rejected on principle:
- Is a passwordless primitive something you would take at all, given #8273?
- If yes — is rpcd the right home for it?
- Would a separate
auth/primary/plugin class be preferable to extending the existing object? I went with extending because identity comes from the filename and keys theluci_plugins.<uuid>section, the display name and the asset prefix all at once, so a second class would split one logical plugin across two uuids — two uci sections and two asset directories for a single credential store. But if you would rather keep the privileged class physically separate, that is easy enough to do instead. - Does such a method need hardening beyond acl.d default-deny — a capability secret rpcd writes to a root-only file, say — or is "simply never grant it" the expected answer here?
Source: openwrt/luci