Skip to content

feat(console): discover and select trusted configurations - #206

Merged
mohanagy merged 11 commits into
developmentfrom
fix/203-console-config-discovery
Jul 24, 2026
Merged

feat(console): discover and select trusted configurations#206
mohanagy merged 11 commits into
developmentfrom
fix/203-console-config-discovery

Conversation

@mohanagy

@mohanagy mohanagy commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Closes #203

Summary

  • Discover validated, private Miftah configurations from the standard config directory when the Console starts without --config.
  • Require an explicit selection, bind it to verified config content, and clear selection after writes or first-run onboarding.
  • Preserve explicit --config behavior and add provider-owned authentication guidance for adapter-backed configurations.

Security impact

  • Discovery accepts only direct, validated configuration files from the bounded standard directory; paths, configuration bytes, and secret values never enter the Console API.
  • Unsafe POSIX permissions, symbolic links, races, malformed configurations, and unverified Windows ACLs fail closed.
  • Windows first-run creation applies a protected current-user file DACL before any configuration content is written, then verifies the persisted owner, canonical DACL, allowed identities, and reparse-point safety.
  • Existing configurations require explicit selection and are revalidated against their verified content before use.

Validation

  • npm test -- --reporter=dot — 1,311 passed, 23 skipped.
  • npm run test:core — 407 passed, 21 skipped.
  • npm run test:oauth-console — 316 passed, 2 skipped.
  • npm run test:coverage — 1,311 passed, 23 skipped; coverage gate passed.
  • npm run lint, npm run typecheck, and npm run build.
  • npm run smoke:cli, npm run check:pack, and npm run test:package.
  • Current-head Linux, macOS, Windows, quality, and review gates are running for 6665dde.

Summary by CodeRabbit

  • New Features

    • Added safe standard-configuration discovery and a configuration catalog with explicit selection for the Console dashboard.
    • Added first-run native OAuth onboarding at ~/.config/miftah/miftah.json without overwriting existing files.
    • Added provider-managed authentication and a clearer configuration status flow.
    • Added local Console API endpoints to list configuration metadata and select a configuration (CSRF protected).
  • Bug Fixes

    • Improved fail-closed handling for unsafe/changed/untrusted configuration files.
    • Added stricter Windows ACL/privacy verification for configuration paths.
  • Documentation

    • Updated CLI and Console API docs to match the new discovery/selection, browser launch, and onboarding behavior.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The dashboard now discovers trusted JSON configurations in the standard directory, presents a selectable catalog, requires explicit selection, and binds operations to verified content. It adds Windows ACL checks, trusted runtime reuse, provider-authentication metadata, new API endpoints, UI flows, tests, and documentation.

Console configuration flow

Layer / File(s) Summary
Trust boundaries and verified sources
src/cli/migrate-config.ts, src/cli/windows-config-acl.ts, src/config/load-config.ts, src/console/console-trusted-configuration.ts
Adds typed migration fingerprints, text-based config loading, Windows private-path verification, and in-memory trusted configuration snapshots.
Trusted catalog and metadata
src/console/console-config-catalog.ts, src/console/console-config-metadata.ts, tests/console-dashboard-application-service.test.ts
Discovers safe configurations, filters invalid or unsafe files, binds entries to content digests, deduplicates identities, and reports authentication metadata.
Dashboard orchestration and selection API
src/cli/main.ts, src/console/console-application-service.ts, src/console/console-dashboard-application-service.ts, src/console/console-server.ts, src/console/console-assets.ts, tests/console-server.test.ts, tests/console-windows-first-run.test.ts
Adds deferred startup validation, catalog and selection endpoints, CSRF enforcement, selection invalidation, provider-authentication UI, onboarding safeguards, and dashboard integration tests.
Trusted runtime and mutations
src/oauth/*, src/runtime/*, tests/console-application-service.test.ts, tests/oauth-connection-command-service.test.ts
Reuses verified configurations for runtime and OAuth operations, while guarded writes use captured migration sources and reject replaced files.
Documentation and error contracts
README.md, docs/*.md, src/utils/errors.ts, src/cli/exit-codes.ts, tests/cli-exit-codes.test.ts
Documents bounded discovery, selection, provider ownership, and mutation behavior, and adds stable console configuration error mappings.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related issues

Possibly related PRs

  • mohanagy/miftah#73 — Introduced the migration compatibility contracts extended here for trusted configuration sources.
  • mohanagy/miftah#183 — Established the Console control API extended with configuration endpoints.
  • mohanagy/miftah#182 — Shares the OAuth runtime factory path now extended to accept verified preloaded configuration.

Poem

A rabbit found configs tucked safe in a row,
Chose one by its bytes, then watched changes show.
“No sneaky swaps!” cried the quick-footed hare,
“Select once again when the file isn’t fair.”
The dashboard blooms, with OAuth in sight—
Secure little carrots by console moonlight.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Docstring Coverage ❌ Error Docstring coverage is 33.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and directly matches the main change: trusted configuration discovery and selection.
Description check ✅ Passed The description includes the required Summary, Security impact, and Validation sections with concrete results.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/203-console-config-discovery

Comment @coderabbitai help to get the list of available commands.

@mohanagy

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Console] Discover and select existing Miftah configurations at startup

1 participant