[evolution-data-server/gnome-42] ESoupSession: Avoid downgrade of Bearer (OAuth2) auth for authentication



commit e8d117282a4fb150fa70505cd4da1d4c6afed71b
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jul 20 15:18:13 2022 +0200

    ESoupSession: Avoid downgrade of Bearer (OAuth2) auth for authentication
    
    When the OAuth2 token expires, the libsoup is notified about it and
    it can re-authenticate, but this time using a different SoupAuth,
    which is not desired here, because the OAuth2 is supposed to be used.

 src/libedataserver/e-soup-session.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/libedataserver/e-soup-session.c b/src/libedataserver/e-soup-session.c
index 381b9f88d..d9d336fe3 100644
--- a/src/libedataserver/e-soup-session.c
+++ b/src/libedataserver/e-soup-session.c
@@ -331,14 +331,19 @@ e_soup_session_authenticate_cb (SoupSession *soup_session,
 
        session = E_SOUP_SESSION (soup_session);
 
+       g_mutex_lock (&session->priv->property_lock);
        if (E_IS_SOUP_AUTH_BEARER (auth)) {
                g_object_ref (auth);
                g_warn_if_fail ((gpointer) session->priv->using_bearer_auth == (gpointer) auth);
                g_clear_object (&session->priv->using_bearer_auth);
                session->priv->using_bearer_auth = E_SOUP_AUTH_BEARER (auth);
+       } else if (session->priv->using_bearer_auth) {
+               /* This can mean the bearer auth expired, then a Basic auth is used by the libsoup;
+                  that's not meant to be done here, thus fail early. */
+               g_mutex_unlock (&session->priv->property_lock);
+               return;
        }
 
-       g_mutex_lock (&session->priv->property_lock);
        if (retrying && !session->priv->auth_prefilled) {
                g_mutex_unlock (&session->priv->property_lock);
                return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]