From: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
To: pdm-devel@lists.proxmox.com
Cc: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
Subject: [PATCH datacenter-manager 1/1] fix #7135: openid auth: improve error logging
Date: Fri, 21 Aug 2026 12:21:47 +0200 [thread overview]
Message-ID: <20260821102147.220586-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.
Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=7135
Signed-off-by: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
Reviewed-by: Nicolas Frey <n.frey@proxmox.com>
---
This patch fixes this: [1] Bugzilla issue, although I'm not
completely sure on the implementation. In the issues discussion, an
improvement of the the error sent to the client is proposed, but I
don't think that to be the correct approach.
To avoid sharing unnecessary information with the client [2], I
instead recommend logging the failed retrieval of an authorization
URL on the server, especially since, in the case of this issue, only
an admin during setup should need this information.
That said, the error logged with this current implementation can be
very verbose, as seen in the example below, although I still find it
useful to understand the state of things.
Options Explored
----------------
- I considered only providing more information to the client for
certain error cases, but our use of the Anyhow crate makes such a
solution a bigger intervention, which I did not find adequate.
- Rather than the current solution, I thought there might be a way to
automatically log an error via the api macro. I looked around, but I
could not find anything similar.
How I tested:
-------------
I spun up a Keycloak instance through Docker and added it as an
OpenId Connect Server to my PDM instance. Since I knowingly
misconfigured it with https instead of http, the attempt to login
then logged the following error (after the patch):
```
# Line breaks added for readability
... proxmox-datacenter-privileged-api[616]: could not get opneid auth url:
Request failed: ureq request failed - native-tls: error:0A00010B:SSL
routines:tls_validate_record_header:wrong version number:
../ssl/record/methods/tlsany_meth.c:77:: native-tls: error:0A00010B:SSL
routines:tls_validate_record_header:wrong version number:
../ssl/record/methods/tlsany_meth.c:77:
```
Changelog
---------
* Since RFC (thanks @Nicolas)
+ Fixing of typos
+ Better explanation in the commit message
[1]: https://bugzilla.proxmox.com/show_bug.cgi?id=7135
[2]: https://cheatsheetseries.owasp.org/cheatsheets/Error_Handling_Cheat_Sheet.html
server/src/api/access/openid.rs | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/server/src/api/access/openid.rs b/server/src/api/access/openid.rs
index 5048fde3..725e1d30 100644
--- a/server/src/api/access/openid.rs
+++ b/server/src/api/access/openid.rs
@@ -271,14 +271,16 @@ pub fn openid_auth_url(
redirect_url: String,
_rpcenv: &mut dyn RpcEnvironment,
) -> Result<String, Error> {
- let (domains, _digest) = pdm_config::domains::config()?;
- let config: OpenIdRealmConfig = domains.lookup("openid", &realm)?;
+ let url_result: Result<String, Error> = try_block!({
+ let (domains, _digest) = pdm_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(PDM_RUN_DIR_M!(), &realm)?;
+ open_id.authorize_url(PDM_RUN_DIR_M!(), &realm)
+ });
- Ok(url)
+ url_result.inspect_err(|err| log::error!("could not get openid auth url: {err:#}"))
}
#[sortable]
--
2.47.3
next reply other threads:[~2026-08-21 10:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 10:21 Thomas Ellmenreich [this message]
2026-08-21 11:35 ` applied: [PATCH datacenter-manager 1/1] fix #7135: openid auth: improve error logging Lukas Wagner
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=20260821102147.220586-1-t.ellmenreich@proxmox.com \
--to=t.ellmenreich@proxmox.com \
--cc=pdm-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.