Files
hermes-agent/hermes_cli/dashboard_auth/__init__.py
ethernet 780d5a3313 fix(auth): login surfaces share one interactive-provider query
Review follow-up (#146139). The native authorize route still counted
every session provider: with session-token beside one password/OAuth
provider an unnamed request 404'd instead of auto-selecting the only
interactive one, and with session-token alone (or named explicitly) it
fell into its start_login stub -> uncaught NotImplementedError -> 500.

registry.list_interactive_providers() is now the single query every
sign-in surface uses: native selection + chooser, the login page,
/api/auth/providers, auto-SSO and the /api/status native_pkce
advertisement (a token-only gate no longer tells Desktop to try a
browser flow it doesn't have). An explicitly named non-interactive
provider is rejected with 400 before any pending broker state exists.
The verify/refresh loops keep list_session_providers.

Tests: native authorize auto-select / token-only / explicit-name cases
and the native_pkce advertisement against the real routes (red without
the fix: the 404 and the 500 above); the dashboard.session_token_auth
opt-out read from a real config.yaml under a temp HERMES_HOME; the REST
bearer test now asserts an exact 200 + provider on /api/auth/me (the old
/api/session target was unrouted, so its 'not 401' passed on a 404).
Docs: the deployment check curls /api/auth/me, not /api/me.
2026-10-28 13:49:47 -04:00

35 lines
1.5 KiB
Python

"""Dashboard authentication provider framework. The auth gate engages only when the dashboard
binds to a non-loopback host without ``--insecure``; every request must then carry a verified
session from a registered ``DashboardAuthProvider`` (Nous provider is the default; third parties
register theirs via the plugin hook ``ctx.register_dashboard_auth_provider``)."""
from hermes_cli.dashboard_auth.base import (
DashboardAuthProvider, Session, TokenPrincipal, LoginStart, InvalidCodeError,
InvalidCredentialsError, ProviderError, RefreshExpiredError, assert_protocol_compliance,
classify_jwks_lookup_error)
# Dashboard-auth providers are persistent host-owned registrations that deliberately survive a routine
# manager unload (#91701), so the "clean slate" reset must drop the process-global auth registry explicitly
# — otherwise a provider auto-registered during one test leaks into the next.
from hermes_cli.dashboard_auth.registry import (
register_provider, get_provider, list_providers, list_token_providers,
list_session_providers, list_interactive_providers, clear_providers)
__all__ = [
"DashboardAuthProvider",
"InvalidCodeError",
"InvalidCredentialsError",
"LoginStart",
"ProviderError",
"RefreshExpiredError",
"Session",
"TokenPrincipal",
"assert_protocol_compliance",
"classify_jwks_lookup_error",
"clear_providers",
"get_provider",
"list_interactive_providers",
"list_providers",
"list_session_providers",
"list_token_providers",
"register_provider",
]