public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
To: pbs-devel@lists.proxmox.com
Cc: Thomas Ellmenreich <t.ellmenreich@proxmox.com>,
	Lukas Wagner <l.wagner@proxmox.com>
Subject: [PATCH proxmox-backup 1/1] openid auth: improve error logging
Date: Mon, 24 Aug 2026 14:57:36 +0200	[thread overview]
Message-ID: <20260824125736.190804-1-t.ellmenreich@proxmox.com> (raw)

Improve logging when getting the authorization URL fails. Previously,
the details of the error were completly swallowed, making it difficult
to diagnose problems connecting to the OpenID Connect Server.

The new log statement prints out the produced error with all of the
contexts provided to `anyhow`, instead of just the one on top of the
stack. Doing so should make OpenID connection errors easier to debug.

The missing log statement came up as an issue in PDM [1], and this
patch now also introduces this to PBS. The original patch in PDM
is: [2].

[1]: https://bugzilla.proxmox.com/show_bug.cgi?id=7135
[2]: https://lore.proxmox.com/pdm-devel/20260821102147.220586-1-t.ellmenreich@proxmox.com/T/#t

Suggested-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
---
As mentioned by @Lukas on the PDM mailing list: [3] the log statement
introduced by this: [2] patch should also be added to PBS for the same
reasons.

As one might notice, this code is a 1 for 1 copy of the PDM code, and as
such should be refactored into a common crate, like proxmox-openid. As that
is a bigger intervention, it will be handled in a future series.

[3]: https://lore.proxmox.com/pdm-devel/178731214859.187715.588193495057111260.b4-ty@proxmox.com/

 src/api2/access/openid.rs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/api2/access/openid.rs b/src/api2/access/openid.rs
index 34f14f467..2e3df269c 100644
--- a/src/api2/access/openid.rs
+++ b/src/api2/access/openid.rs
@@ -321,14 +321,16 @@ fn openid_auth_url(
     redirect_url: String,
     _rpcenv: &mut dyn RpcEnvironment,
 ) -> Result<String, Error> {
-    let (domains, _digest) = pbs_config::domains::config()?;
-    let config: OpenIdRealmConfig = domains.lookup("openid", &realm)?;
+    let url_result = proxmox_lang::try_block!({
+        let (domains, _digest) = pbs_config::domains::config()?;
+        let config: OpenIdRealmConfig = domains.lookup("openid", &realm)?;
 
-    let open_id = openid_authenticator(&config, &redirect_url)?;
+        let open_id = openid_authenticator(&config, &redirect_url)?;
 
-    let url = open_id.authorize_url(PROXMOX_BACKUP_RUN_DIR_M!(), &realm)?;
+        open_id.authorize_url(PROXMOX_BACKUP_RUN_DIR_M!(), &realm)
+    });
 
-    Ok(url)
+    url_result.inspect_err(|err| log::error!("could not get openid auth url: {err:#}"))
 }
 
 #[sortable]
-- 
2.47.3





                 reply	other threads:[~2026-08-24 12:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260824125736.190804-1-t.ellmenreich@proxmox.com \
    --to=t.ellmenreich@proxmox.com \
    --cc=l.wagner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal