[gnome-software] snapd: Drop unused Macaroon code - it will be replaced by a better implementation



commit 2bfbe9c72e7b8cc51a8e4fd2525d7f9d5f4cba70
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon Jul 4 15:02:09 2016 +1200

    snapd: Drop unused Macaroon code - it will be replaced by a better implementation

 src/plugins/gs-plugin-snap.c |   39 +++++++++++++++----------------
 src/plugins/gs-snapd.c       |   52 ------------------------------------------
 src/plugins/gs-snapd.h       |    3 --
 3 files changed, 19 insertions(+), 75 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snap.c b/src/plugins/gs-plugin-snap.c
index 3e15380..52df0ba 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -124,9 +124,9 @@ refine_app (GsPlugin *plugin, GsApp *app, JsonObject *package)
                g_autofree gchar *icon_response = NULL;
                gsize icon_response_length;
 
-               if (gs_snapd_request ("GET", icon_url, NULL, NULL, TRUE, NULL,
-                                     NULL, NULL, NULL,
-                                     &icon_response, &icon_response_length,
+               if (gs_snapd_request ("GET", icon_url, NULL,
+                                     NULL, NULL,
+                                     NULL, &icon_response, &icon_response_length,
                                      NULL)) {
                        g_autoptr(GdkPixbufLoader) loader = NULL;
 
@@ -207,10 +207,10 @@ get_apps (GsPlugin *plugin,
                g_string_append (path, fields);
        }
        g_ptr_array_free (query_fields, TRUE);
-       if (!gs_snapd_request ("GET", path->str, NULL, NULL, TRUE, NULL,
+       if (!gs_snapd_request ("GET", path->str, NULL,
                               &status_code, &reason_phrase,
-                              &response_type, &response,
-                              NULL, error))
+                              &response_type, &response, NULL,
+                              error))
                return FALSE;
 
        if (status_code != SOUP_STATUS_OK) {
@@ -271,10 +271,10 @@ get_app (GsPlugin *plugin, GsApp *app, GError **error)
        guint i;
 
        path = g_strdup_printf ("/v2/snaps/%s", gs_app_get_id (app));
-       if (!gs_snapd_request ("GET", path, NULL, NULL, TRUE, NULL,
+       if (!gs_snapd_request ("GET", path, NULL,
                               &status_code, &reason_phrase,
-                              &response_type, &response,
-                              NULL, error))
+                              &response_type, &response, NULL,
+                              error))
                return FALSE;
 
        if (status_code == SOUP_STATUS_NOT_FOUND) {
@@ -284,10 +284,10 @@ get_app (GsPlugin *plugin, GsApp *app, GError **error)
                g_clear_pointer (&response, g_free);
 
                path = g_strdup_printf ("/v2/find?q=%s", gs_app_get_id (app));
-               if (!gs_snapd_request ("GET", path, NULL, NULL, TRUE, NULL,
+               if (!gs_snapd_request ("GET", path, NULL,
                                       &status_code, &reason_phrase,
-                                      &response_type, &response,
-                                      NULL, error))
+                                      &response_type, &response, NULL,
+                                      error))
                        return FALSE;
        }
 
@@ -401,14 +401,13 @@ send_package_action (GsPlugin *plugin,
         const gchar *resource_path;
        const gchar *type;
        const gchar *change_id;
-       g_autoptr(GVariant) macaroon = NULL;
 
        content = g_strdup_printf ("{\"action\": \"%s\"}", action);
        path = g_strdup_printf ("/v2/snaps/%s", id);
-       if (!gs_snapd_request ("POST", path, content, NULL, TRUE,
-                              &macaroon, &status_code,
-                              &reason_phrase, &response_type,
-                              &response, NULL, error))
+       if (!gs_snapd_request ("POST", path, content,
+                              &status_code, &reason_phrase,
+                              &response_type, &response, NULL,
+                              error))
                return FALSE;
 
        if (status_code != SOUP_STATUS_ACCEPTED) {
@@ -440,10 +439,10 @@ send_package_action (GsPlugin *plugin,
                        /* Wait for a little bit before polling */
                        g_usleep (100 * 1000);
 
-                       if (!gs_snapd_request ("GET", resource_path, NULL, macaroon, TRUE, NULL,
+                       if (!gs_snapd_request ("GET", resource_path, NULL,
                                               &status_code, &status_reason_phrase,
-                                              &status_response_type, &status_response,
-                                              NULL, error)) {
+                                              &status_response_type, &status_response, NULL,
+                                              error)) {
                                return FALSE;
                        }
 
diff --git a/src/plugins/gs-snapd.c b/src/plugins/gs-snapd.c
index c11b1ce..3fc75bc 100644
--- a/src/plugins/gs-snapd.c
+++ b/src/plugins/gs-snapd.c
@@ -94,9 +94,6 @@ gboolean
 gs_snapd_request (const gchar  *method,
                  const gchar  *path,
                  const gchar  *content,
-                 GVariant     *macaroon,
-                 gboolean      retry_after_login,
-                 GVariant    **out_macaroon,
                  guint        *status_code,
                  gchar       **reason_phrase,
                  gchar       **response_type,
@@ -112,11 +109,7 @@ gs_snapd_request (const gchar  *method,
        g_autoptr (SoupMessageHeaders) headers = NULL;
        gsize chunk_length, n_required;
        gchar *chunk_start = NULL;
-       const gchar *root;
-       const gchar *discharge;
-       GVariantIter *iter;
        guint code;
-       gboolean ret;
 
        // NOTE: Would love to use libsoup but it doesn't support unix sockets
        // https://bugzilla.gnome.org/show_bug.cgi?id=727563
@@ -128,16 +121,6 @@ gs_snapd_request (const gchar  *method,
        request = g_string_new ("");
        g_string_append_printf (request, "%s %s HTTP/1.1\r\n", method, path);
        g_string_append (request, "Host:\r\n");
-       if (macaroon != NULL) {
-               g_variant_get (macaroon, "(&sas)", &root, &iter);
-               g_string_append_printf (request, "Authorization: Macaroon root=\"%s\"", root);
-
-               while (g_variant_iter_next (iter, "&s", &discharge))
-                       g_string_append_printf (request, ",discharge=\"%s\"", discharge);
-
-               g_variant_iter_free (iter);
-               g_string_append (request, "\r\n");
-       }
        if (content)
                g_string_append_printf (request, "Content-Length: %zi\r\n", strlen (content));
        g_string_append (request, "\r\n");
@@ -187,39 +170,6 @@ gs_snapd_request (const gchar  *method,
        if (status_code != NULL)
                *status_code = code;
 
-       if ((code == 401 || code == 403) && retry_after_login) {
-               g_socket_close (socket, NULL);
-
-               if (macaroon == NULL) {
-                       g_set_error_literal (error,
-                                            GS_PLUGIN_ERROR,
-                                            GS_PLUGIN_ERROR_AUTH_REQUIRED,
-                                            "failed to authenticate");
-                       return FALSE;
-               }
-
-               ret = gs_snapd_request (method,
-                                       path,
-                                       content,
-                                       macaroon,
-                                       FALSE,
-                                       NULL,
-                                       status_code,
-                                       reason_phrase,
-                                       response_type,
-                                       response,
-                                       response_length,
-                                       error);
-
-               if (ret && out_macaroon != NULL) {
-                       *out_macaroon = macaroon;
-               } else {
-                       g_variant_unref (macaroon);
-               }
-
-               return ret;
-       }
-
        /* work out how much data to follow */
        if (g_strcmp0 (soup_message_headers_get_one (headers, "Transfer-Encoding"),
                       "chunked") == 0) {
@@ -281,8 +231,6 @@ gs_snapd_request (const gchar  *method,
                                      error))
                        return FALSE;
 
-       if (out_macaroon != NULL)
-               *out_macaroon = g_variant_ref (macaroon);
        if (response_type)
                *response_type = g_strdup (soup_message_headers_get_one (headers, "Content-Type"));
        if (response) {
diff --git a/src/plugins/gs-snapd.h b/src/plugins/gs-snapd.h
index 58ac6fe..fadfaa4 100644
--- a/src/plugins/gs-snapd.h
+++ b/src/plugins/gs-snapd.h
@@ -29,9 +29,6 @@ gboolean gs_snapd_exists      (void);
 gboolean gs_snapd_request      (const gchar    *method,
                                 const gchar    *path,
                                 const gchar    *content,
-                                GVariant       *macaroon,
-                                gboolean        retry_after_login,
-                                GVariant       **out_macaroon,
                                 guint          *status_code,
                                 gchar          **reason_phrase,
                                 gchar          **response_type,


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