feat(plugins): add register_dashboard_auth_provider hook on PluginContext

Phase 1, Task 1.3. Mirrors the existing register_image_gen_provider
pattern (plugins.py:531) — wrong-type or duplicate-name registrations
log at WARNING and silently return rather than raising, so a misbehaving
auth plugin cannot crash the host.

Deviation from plan: the plan's draft raised TypeError on non-provider
input; switched to silent-warn to match the established image_gen
convention. Test updated to match.
This commit is contained in:
Ben 2026-05-21 15:09:56 +10:00
parent e5543f818a
commit f4093b6b92
2 changed files with 130 additions and 0 deletions

View file

@ -553,6 +553,46 @@ class PluginContext:
self.manifest.name, provider.name,
)
# -- dashboard auth provider registration --------------------------------
def register_dashboard_auth_provider(self, provider) -> None:
"""Register a dashboard authentication provider.
``provider`` must be an instance of
:class:`hermes_cli.dashboard_auth.DashboardAuthProvider`. Used by
the dashboard OAuth auth gate, which engages when the dashboard
binds to a non-loopback host without ``--insecure``.
Misbehaving providers (wrong type, duplicate name) are logged at
WARNING and silently ignored never raised so a broken plugin
cannot crash the host. Same convention as
``register_image_gen_provider``.
"""
from hermes_cli.dashboard_auth import (
DashboardAuthProvider, register_provider,
)
if not isinstance(provider, DashboardAuthProvider):
logger.warning(
"Plugin '%s' tried to register a dashboard-auth provider "
"that does not inherit from DashboardAuthProvider. Ignoring.",
self.manifest.name,
)
return
try:
register_provider(provider)
except (TypeError, ValueError) as e:
logger.warning(
"Plugin '%s' failed to register dashboard-auth provider "
"%r: %s",
self.manifest.name, getattr(provider, "name", "?"), e,
)
return
logger.info(
"Plugin '%s' registered dashboard-auth provider: %s (%s)",
self.manifest.name, provider.name, provider.display_name,
)
# -- video gen provider registration -------------------------------------
def register_video_gen_provider(self, provider) -> None: