From 18db9d6cb3ee5b8318314373c40b078a296e0d3d Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Tue, 12 May 2026 23:56:44 +0200 Subject: [PATCH] refactor: prune dead pre-LOGIN_FLOW config/runtime branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two small post-merge cleanups deferred from PR #787 (ADR-022 follow-up). Both were explicitly noted in the reviewer's "acknowledged deferred items" list. 1. config.py: drop `enable_multi_user_basic_auth` and `enable_login_flow` from the dynaconf `_DEFAULTS` dict. They were removed from `_field_map` in PR #787, so `get_settings()` never read them anyway, but their presence in `_DEFAULTS` was visually misleading — readers might think they could be set via TOML when in fact `Settings.__post_init__` derives them from `MCP_DEPLOYMENT_MODE`. Replaced with a NOTE comment pointing at the canonical derivation site. 2. app.py: the lifespan code had `use_basic_auth = not oauth_enabled or settings.enable_login_flow`, which became always-True once PR #787 enforced `oauth_enabled ↔ enable_login_flow` via __post_init__. Hard-coded to `True` with a comment explaining the invariant and pointing at the separate follow-up that will prune the now-unreachable `use_basic_auth=False` code paths in `vector/oauth_sync.py` (which includes deleting the `use_basic_auth` parameter from `user_manager_task` / `oauth_processor_task` and the OAuth-token-refresh branch in `get_user_client`). Kept the variable name and the call-site conditionals as-is for now so that follow-up is a clean mechanical diff. No runtime behaviour change: `use_basic_auth` already evaluated to True in every supported mode after PR #787, and the `_DEFAULTS` entries were already shadowed by `__post_init__`. Co-Authored-By: Claude Opus 4.7 (1M context) --- nextcloud_mcp_server/app.py | 17 +++++++++++++---- nextcloud_mcp_server/config.py | 5 +++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/nextcloud_mcp_server/app.py b/nextcloud_mcp_server/app.py index 5bdedf86..3fa99a47 100644 --- a/nextcloud_mcp_server/app.py +++ b/nextcloud_mcp_server/app.py @@ -1789,10 +1789,19 @@ def get_app(transport: str = "streamable-http", enabled_apps: list[str] | None = ) break - # Determine authentication mode for background sync - # Login Flow v2 and multi-user BasicAuth: use app passwords - # OAuth mode (without Login Flow): use OAuth refresh tokens - use_basic_auth = not oauth_enabled or settings.enable_login_flow + # Background sync always uses app passwords post-ADR-022: + # `oauth_enabled` now implies `enable_login_flow` (single + # source of truth is `MCP_DEPLOYMENT_MODE`), so the old + # `not oauth_enabled or settings.enable_login_flow` was always + # True. The OAuth-refresh code paths in + # `vector/oauth_sync.py` (gated on `use_basic_auth=False`) + # are now unreachable; pruning them — and dropping the + # `use_basic_auth` parameter from `user_manager_task` / + # `oauth_processor_task` — is tracked as a separate + # follow-up. Keep the variable name + the conditional + # wiring at the call sites for now so the parallel-prune + # PR is a clean mechanical diff. + use_basic_auth = True # Start background tasks using anyio TaskGroup async with anyio.create_task_group() as tg: diff --git a/nextcloud_mcp_server/config.py b/nextcloud_mcp_server/config.py index 62eca989..25347c21 100644 --- a/nextcloud_mcp_server/config.py +++ b/nextcloud_mcp_server/config.py @@ -43,8 +43,9 @@ _DEFAULTS: dict[str, Any] = { "userinfo_uri": None, "oidc_resource_server_id": None, # Mode flags - "enable_multi_user_basic_auth": False, - "enable_login_flow": False, + # NOTE: `enable_multi_user_basic_auth` and `enable_login_flow` are + # intentionally absent — they are derived from MCP_DEPLOYMENT_MODE in + # Settings.__post_init__ (ADR-022) and not read from the dynaconf store. "enable_semantic_search": False, "enable_background_operations": False, "vector_sync_enabled": False,