public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox-backup 1/1] openid auth: improve error logging
@ 2026-08-24 12:57 Thomas Ellmenreich
  0 siblings, 0 replies; only message in thread
From: Thomas Ellmenreich @ 2026-08-24 12:57 UTC (permalink / raw)
  To: pbs-devel; +Cc: Thomas Ellmenreich, Lukas Wagner

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





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-24 12:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 12:57 [PATCH proxmox-backup 1/1] openid auth: improve error logging Thomas Ellmenreich

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