File 0001-Revert-goa-oauth2-handler-drop-constraint-on-client-.patch of Package gnome-online-accounts

From a6392c646c3b919980ce714c1d3446d3d9801d43 Mon Sep 17 00:00:00 2001
From: tigro <tigro@msvsphere-os.ru>
Date: Wed, 24 Dec 2025 17:24:13 +0300
Subject: [PATCH] Revert "goa-oauth2-handler: drop constraint on client IDs"

This reverts commit 7b34f6858e6a35bd5233a1c088db320302f67ec7.
---
 src/goabackend/goaoauth2handler.c | 55 +++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 3 deletions(-)

diff --git a/src/goabackend/goaoauth2handler.c b/src/goabackend/goaoauth2handler.c
index 7dbc5dc1..48299852 100644
--- a/src/goabackend/goaoauth2handler.c
+++ b/src/goabackend/goaoauth2handler.c
@@ -27,6 +27,55 @@
 #define OAUTH2_DBUS_HANDLER_PATH  "/org/gnome/OnlineAccounts/OAuth2"
 #define OAUTH2_DBUS_HANDLER_IFACE "org.gnome.OnlineAccounts.OAuth2"
 
+static struct
+{
+  const char *client_id;
+}
+oauth2_providers[] =
+{
+#ifdef GOA_GOOGLE_ENABLED
+  {
+    .client_id = GOA_GOOGLE_CLIENT_ID,
+  },
+#endif
+#ifdef GOA_WINDOWS_LIVE_ENABLED
+  {
+    .client_id = GOA_WINDOWS_LIVE_CLIENT_ID,
+  },
+#endif
+#ifdef GOA_MS_GRAPH_ENABLED
+    {
+    .client_id = GOA_MS_GRAPH_CLIENT_ID,
+    },
+#endif
+#ifdef GOA_YANDEX_ENABLED
+  {
+    .client_id = GOA_YANDEX_CLIENT_ID,
+  },
+#endif
+  { NULL },
+};
+
+static gboolean
+get_oauth2_provider (const char  *needle,
+                     const char **client_out)
+{
+  g_return_val_if_fail (needle != NULL, FALSE);
+
+  for (unsigned int i = 0; oauth2_providers[i].client_id != NULL; i++)
+    {
+      if (g_str_equal (needle, oauth2_providers[i].client_id))
+        {
+          if (client_out)
+            *client_out = oauth2_providers[i].client_id;
+
+          return TRUE;
+        }
+    }
+
+  return FALSE;
+}
+
 int
 main (int    argc,
       char **argv)
@@ -58,10 +107,10 @@ main (int    argc,
    * See: https://developers.google.com/identity/protocols/oauth2/native-app
    */
   scheme = g_uri_get_scheme (uri);
-  if (scheme != NULL && strstr (scheme, "."))
+  if (scheme != NULL)
     {
       g_auto (GStrv) strv = g_strsplit (scheme, ".", -1);
-      GString *tmp = g_string_new ("");
+      g_autoptr (GString) tmp = g_string_new ("");
 
       for (unsigned int i = 0; strv[i] != NULL; i++)
         {
@@ -70,7 +119,7 @@ main (int    argc,
           g_string_prepend (tmp, strv[i]);
         }
 
-      client_id = g_string_free (tmp, FALSE);
+      get_oauth2_provider (tmp->str, &client_id);
     }
 
   /* Treat first path segment as client id */
-- 
2.52.0

openSUSE Build Service is sponsored by