fix(auth): address PR #757 round-2 review feedback

Four review items from the second-round review on PR #757:

- scope_authorization: broaden the post-elicit retry message to acknowledge
  the 5-minute scope-cache TTL — if the LFv2 poller is still in-flight at
  acknowledge-time, the immediate retry can still hit a stale cache.
- elicitation: extract a shared `_run_elicit(ctx, message, schema, *,
  log_label)` helper so `present_login_url` and
  `present_provisioning_required` no longer duplicate the
  hasattr-guard / try-NotImplementedError / try-Exception fallback block.
  The data-acknowledged warning specific to login-flow stays in
  `present_login_url` so behaviour is preserved exactly.
- elicitation: detect missing http:// / https:// scheme in
  `_astrolabe_settings_url`, log a warning, and return None — caller
  renders the safe tool-only fallback instead of producing a broken link.
  New unit test locks this in.
- browser_oauth_routes: replace the stray
  `os.getenv(\"NEXTCLOUD_HOST\")` in `_should_use_secure_cookies` with
  `get_settings().nextcloud_host` for consistency with the rest of the
  file (PR #757 review nit).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-05-02 16:33:43 +02:00
co-authored by Claude Opus 4.7
parent f3256e515e
commit 7464340763
4 changed files with 116 additions and 75 deletions
@@ -168,11 +168,19 @@ def require_scopes(*required_scopes: str):
# elicitation isn't told to call the auth tool
# again (which would loop).
if elicit_result == "accepted":
# Note: stored-scope lookups are cached for
# _SCOPE_CACHE_TTL (5 min). Both nc_auth_provision_access
# and the Astrolabe web route invalidate the cache when
# they finish, but if the LFv2 poller is still in-flight
# at acknowledge-time the next retry can still hit the
# stale cache — hence the "wait a moment" qualifier.
error_msg = (
f"Access denied to {func_name}: Nextcloud "
f"access was not provisioned at the time of "
f"this call. If you just completed "
f"provisioning, please retry the request."
f"provisioning, please retry the request"
f"if it still fails, provisioning may still be "
f"completing; wait a moment and try again."
)
else:
error_msg = (