Commit Graph

15 Commits

Author SHA1 Message Date
Maciej Lisiewski
3b0a5e728d fix(dashboard-auth): logout revokes by access token and Basic skips the refresh replay cache
A session_ttl_seconds above the 30-day refresh TTL left a logout after day 30
with no refresh token to revoke, so a copied access token kept working; logout
now also hands the access-token cookie to revoke_access_session (Basic revokes
its sid). Basic refresh tokens stay valid after use, so a copied RT's cached
rotation could outlive a logout that presented the browser's newer RT; Basic
opts out of success caching via refresh_reuse_detection = False. Adds tests
that kill the forget() link, generation and read-before-write mutants.
2026-11-12 15:55:24 +01:00
Maciej Lisiewski
549bde85e4 fix(dashboard-auth): logout also ends cached refreshes and long-TTL tokens
Three gaps in the basic-auth logout from review:
- revocation lasted only the refresh TTL, so with session_ttl_seconds above
  30 days a logged-out access token worked again before it expired;
- the refresh replay cache kept handing a copied RT the rotated session for
  up to 30s after logout; logout now drops that login's cached rotations
  (following the rotation chain) and bars in-flight refreshes from caching;
- a worker skipped re-reading the revocation file when its mtime was
  unchanged (coarse-timestamp filesystems), missing another worker's logout
  and later overwriting it; the small file is now read every check.

Refs #77186
2026-11-12 15:55:24 +01:00
Maciej Lisiewski
02ba28abd3 fix(dashboard-auth): end basic-auth sessions on logout and credential change
The basic provider's tokens were signed only with the configured secret and
revoke_session() was a no-op, so a copied token outlived logout for its full
TTL (30d via refresh) and rotating the password while keeping an explicit
secret left every old session valid.

Tokens are now signed with a key derived from the secret plus the username and
a restart-stable form of the password (the plaintext when it is hashed
in-memory with a fresh salt each start), so a credential change ends all
sessions. Each login carries a sid that renewals keep; logout records it in
<hermes home>/dashboard_auth/basic-revoked-sessions.json (pruned past the
refresh TTL), which every process sharing the secret re-reads on change.

Fixes #77186
2026-11-12 15:55:24 +01:00
unsupportedpastels
074d150fab fix(dashboard-auth): print the ignored basic-auth secret notice once on stderr
The error for a signing secret holding shell text only reached agent.log and
errors.log, so an operator watching the console of hermes serve or hermes
dashboard saw nothing and was only signed out on every restart. Print one line
on stderr the first time such a secret is ignored in a process. The line names
the setting and the fix but never the configured value.
2026-10-27 16:37:10 -04:00
unsupportedpastels
0323a30052 fix(dashboard-auth): treat a pasted openssl rand command as an unset basic-auth secret
The basic provider already ignores a signing secret holding $( or a backtick.
A secret that is the command itself (openssl rand -base64 32), a spaced
"$ (...)", or the web-dashboard.md placeholder
"<32+ random bytes; openssl rand -base64 32>" pasted as-is was still used as
a fixed, known key. Also match "openssl rand": base64 and hex output never
contains a space, so no generated secret can match it.
2026-10-27 16:37:10 -04:00
unsupportedpastels
50e14f7dd8 docs(dashboard): generate the basic-auth signing secret in the remote recipes
The remote-backend recipes in desktop.md and web-dashboard.md wrote the
HERMES_DASHBOARD_BASIC_AUTH_SECRET line inside a quoted heredoc, so .env got the
literal text $(openssl rand -base64 32) instead of a random secret. Write the
credentials with the quoted heredoc and append the secret with a real command
substitution, and tell readers how to spot and replace the literal line.

The basic provider now ignores a signing secret that still contains unexpanded
shell text ($( or a backtick), logs an error, and uses a random per-process key,
so the literal string is never used to sign or verify sessions.
2026-10-27 16:37:10 -04:00
unsupportedpastels
9ed6c20651 fix(dashboard-auth): give every password-provider session its own tokens
The password provider signed only the user, kind and whole-second expiry,
so two sign-ins in the same second got the same token pair. On the
Webapp's listener a browser login's tokens work only as its cookies, but
when a native app signed in with the password provider in the same second
as a browser login, the record of the app's pair matched the login's
tokens too: they worked on their own as a bearer token and on the refresh
route, and kept working after hermes webapp --sign-out and a restart.
Each minted session now carries a random jti, so every login, sign-in and
renewal gets its own pair; tokens still verify as before. Native apps stay
signed in across a sign-out, as before.

Rebuilt from ac1d76b459921bb371d30227e2d6dfba8224ae71 (#145108), with the
Webapp test rewritten for the contract that native apps stay signed in.
2026-10-26 18:15:25 -04:00
Teknium
a5bd246865 Old pre-decomposition import paths are gone: plugin compat layer removed on schedule (#126164)
* refactor(plugins): remove the Sep 2026 decomposition compat layer on schedule

The PLUGIN-COMPAT layer (2776813df3 + d63e380324 + 0a5164cebe) kept pre-#102117 import paths
alive for external plugins until 2026-09-14. That window closed two weeks ago; since then the loader
has already been skipping plugins that use the old paths. This removes the layer itself:

- 328 appended `PLUGIN-COMPAT` blocks (lazy `__getattr__` pointer tables, re-exported third-party
  names, restored dead definitions) and the three re-export stub modules
  (gateway/startup_watchdog, hermes_cli/observability/relay_runtime, tools/environments/modal_utils)
- COMPAT_MANIFEST.md, compat_manifest.json, scripts/check_compat_pointers.py and its lint step
- the reporting surfaces: CLI banner notice, `hermes plugins compat`, the `hermes doctor` section,
  the post-update notice, the Desktop one-time dialog, the loader's pre-import skip and the
  `plugins.allow_deprecated_imports` escape hatch

An external plugin that still imports an old path now fails to load with its ImportError as the
reason in `hermes plugins list`, the same path as any broken plugin.

hermes_cli/plugin_compat.py stays as three inert stubs (compat_report, removal_in_effect,
summary_lines): an already-running pre-removal `hermes update` lazy-imports them after the checkout
swap (tests/compat/old_updater_surface.json).

In-tree fallout, both already dead: hermes_cli/setup.py::_check_espeak_ng (no callers; its
`shutil` came from a compat block) and gateway/config.py::SessionResetPolicy ("retained solely for
the scheduled plugin-compat window"). Two test_run_agent patches targeted the removed
`run_agent.handle_function_call` pointer; they now patch `model_tools.handle_function_call`, the
seam production reads, like every sibling test in that file.

* chore: retrigger CI (zero-job startup_failure phantom)

* test: drop resolution allowlist rows for the two deleted which() sites

hermes_cli/setup.py::_check_espeak_ng (dead) and tools/skillevaluator_scan.py::scanner_available
(a restored definition inside a PLUGIN-COMPAT block) no longer exist; the stale-row gate requires
their allowlist entries go with them.
2026-09-28 10:21:41 -07:00
Teknium
d63e380324 compat(plugins): warn once per name when a plugin resolves an old import path; lint step restored in CI
Every PLUGIN-COMPAT __getattr__ now calls hermes_cli.plugin_compat.warn_once(facade, name, target) before
resolving, emitting a HermesPluginCompatWarning (FutureWarning) once per process per name: old path, new
path, removal target. Importing a facade for its live API stays silent; only resolving a moved name warns.
COMPAT_MANIFEST.md documents the warning and how to silence it during migration.

Verified the runtime never routes through a pointer: every entry point (run_agent, cli, hermes_cli.main,
gateway.run, tui_gateway.server, web_server, model_tools + tool discovery, hermes_state, cron.scheduler,
browser_tool, mcp_tool, kanban, auth) imports clean and `hermes doctor` runs end to end with the warning
promoted to an error.

Also restores the check_compat_pointers CI step to .github/workflows/lint.yml, which a0be177aac dropped
when the compat layer was regenerated (the lint script itself was present; the workflow step was not).

hermes_cli/plugin_compat.py, tests/test_plugin_compat_warning.py and the two-line insert per facade are
part of the compat layer and go away with it.
2026-09-04 00:15:16 -07:00
Teknium
2776813df3 compat(plugins): temporary import-path shims for external plugins — ONE commit, revert on schedule
The Sep 2026 decomposition (PR #102117) makes internal import paths a non-API: names now live in
the focused modules that define them. This commit is the ONLY thing keeping the old paths alive,
so external plugins have time to update. It is deliberately a single, unsquashed commit:

    git revert <this sha>

removes every shim, stub and manifest at once on the announced date. Nothing in-tree may depend on
these pointers: scripts/check_compat_pointers.py (wired into lint.yml) fails CI if it does.

What it adds (see COMPAT_MANIFEST.md, compat_manifest.json):
- 332 facade modules get one delimited `PLUGIN-COMPAT` block appended at the end of the file
- 1,172 moved names resolved lazily via a module `__getattr__` (PEP 562) — never a top-level import,
  so no import cycles; facades that already had `__getattr__` get a chained one
- 592 third-party/stdlib names the old modules used to expose, with their original import statements
- 266 public definitions that had been deleted as unused, restored byte-for-byte from the pre-decomposition
  tree (+40 private helpers and 16 imports pulled in only because a restored definition needs them)
- 3 deleted modules recreated as re-export stubs (gateway/startup_watchdog, hermes_cli/observability/
  relay_runtime, tools/environments/modal_utils)
- private names (`_x`) get no pointer: they were never API (3,792 skipped)

Verified: all 335 touched modules import under a fresh HERMES_HOME and every manifest name resolves;
the lint reports zero in-tree uses; ruff clean; targeted suites unchanged.
2026-09-03 17:13:22 -07:00
Teknium
d20d37e5e0 refactor(plugins/dashboard_auth): JwtOAuthProvider base (complete/refresh/verify + JWKS client) and NonInteractiveMixin in _shared; nous/self_hosted/basic/drain become thin subclasses 2026-09-02 22:45:15 -07:00
Teknium
eccfcb5f8e refactor(plugins/hermes-achievements,dashboard_auth): unify snapshot/scan_meta/result builders, drop dead evaluate_boolean + import shims, compact module docstrings, AST-neutral layout 2026-09-02 21:43:13 -07:00
Teknium
e986577dca refactor(plugins/kanban,dashboard_auth): split update_task/bulk_update into phase helpers, dict-driven orchestration writes; unify provider register() via _shared.register_provider/SkipRegistration 2026-09-02 21:09:26 -07:00
Teknium
238260e6aa refactor(plugins/dashboard_auth): shared session/JWT/config helpers in _shared; compact basic/drain/nous/self_hosted 2026-09-02 13:30:10 -07:00
Ben
acb0e2bacb feat(dashboard-auth): add BasicAuthProvider username/password plugin
A bundled, zero-infrastructure 'just put a password on my dashboard'
provider that uses the supports_password extension point. No external IDP,
no database: sessions are stateless HMAC-signed tokens the provider mints
and verifies itself, and passwords are hashed with stdlib scrypt (no
third-party dependency — deliberately avoids bcrypt to keep the dep
surface unchanged).

  - plugins/dashboard_auth/basic: BasicAuthProvider (scrypt verify with a
    constant-time dummy-hash path for unknown users so the endpoint is not
    a username-timing oracle; access/refresh tokens carry a 'kind' claim
    that verify/refresh enforce; cross-secret tokens are rejected). The
    register() entry point mirrors the Nous plugin's config/env precedence
    (env wins; empty treated as unset) and LAST_SKIP_REASON channel.
  - config.py: document the canonical dashboard.basic_auth.* surface
    (username / password_hash / password / secret / session_ttl_seconds).

Activates only when username + (password or password_hash) are set, so
OAuth users and loopback/--insecure operators are unaffected. Without an
explicit secret a random per-process key is generated (logged): fine for a
single process, but sessions then don't survive restart or span workers.
2026-06-04 01:02:25 -07:00