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

Three review items from the third-round review on PR #757:

- scope_authorization: split the combined logger.warning(error_msg) in
  the require_scopes decorator's missing-app-password branch into two
  lazy %-style logger calls (one per branch), keeping the f-string
  error_msg for the exception only. The else branch also logs the
  elicit_result for diagnostics. Bypassing lazy %-interpolation in
  security-sensitive code formatted the message regardless of log level
  and matched the repo-wide lazy-logging preference; the new code now
  conforms.
- config + browser_oauth_routes: wire COOKIE_SECURE through Settings
  (cookie_secure: bool | None = None) so _should_use_secure_cookies()
  reads it via get_settings() rather than os.getenv. Completes the
  consolidation pass that touched this file in commit 7464340 and
  removes the last raw os.getenv from browser_oauth_routes.py
  (import os dropped). Dynaconf auto-coerces "true"/"false" → bool;
  "1"/"0" arrive as int and are normalised by an explicit bool() at
  the consumer.
- elicitation: clarify the _astrolabe_settings_url docstring to call
  out that the empty-string case is also a None-return path (matches
  the existing `if not base:` guard).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-05-02 17:24:50 +02:00
co-authored by Claude Opus 4.7
parent f31d0544b7
commit ce80a36877
4 changed files with 33 additions and 17 deletions
@@ -179,6 +179,11 @@ def require_scopes(*required_scopes: str):
# time the next retry can still hit a not-yet-
# populated entry — hence the "wait a moment"
# qualifier below.
logger.warning(
"Access denied to %s: app password missing "
"after user accepted elicitation; advising retry",
func_name,
)
error_msg = (
f"Access denied to {func_name}: Nextcloud "
f"access was not provisioned at the time of "
@@ -188,12 +193,18 @@ def require_scopes(*required_scopes: str):
f"completing; wait a moment and try again."
)
else:
logger.warning(
"Access denied to %s: app password missing; "
"advising nc_auth_provision_access "
"(elicit_result=%s)",
func_name,
elicit_result,
)
error_msg = (
f"Access denied to {func_name}: "
f"Nextcloud access not provisioned. "
f"Please call 'nc_auth_provision_access' first."
)
logger.warning(error_msg)
raise ProvisioningRequiredError(error_msg)
if stored_scopes == "all":