[librest/release_0_9_1] Remove oauth1 proxy



commit ff21917e75422a30019b0dbc933ea898717932b7
Author: Günther Wagner <info gunibert de>
Date:   Sun Jun 19 11:10:14 2022 +0200

    Remove oauth1 proxy
    
    OAuth1 is discouraged to be used nowadays. Only flickr is the only
    service we used in the past which needed oauth1. They probably
    won't update their API to OAuth2 and therefore it was dropped
    in GOA. Following this example, dropping OAuth1 support too for librest.

 examples/continuous-twitter.c   |  90 -----
 examples/demo/demo-rest-page.c  | 165 +--------
 examples/demo/demo-rest-page.ui |  73 ----
 examples/meson.build            |   3 -
 examples/post-twitter-media.c   | 101 -----
 examples/post-twitter.c         |  77 ----
 rest/meson.build                |  22 +-
 rest/oauth-proxy-call.c         | 391 -------------------
 rest/oauth-proxy-call.h         |  51 ---
 rest/oauth-proxy.c              | 803 ----------------------------------------
 rest/oauth-proxy.h              | 110 ------
 rest/rest.h                     |   2 -
 rest/test-runner.c              |  34 --
 13 files changed, 2 insertions(+), 1920 deletions(-)
---
diff --git a/examples/demo/demo-rest-page.c b/examples/demo/demo-rest-page.c
index e36fee7..d33d7b6 100644
--- a/examples/demo/demo-rest-page.c
+++ b/examples/demo/demo-rest-page.c
@@ -52,12 +52,6 @@ struct _DemoRestPage
   GtkWidget *digest_username;
   GtkWidget *digest_password;
 
-  /* oauth 1 auth */
-  GtkWidget *oauth1_client_identifier;
-  GtkWidget *oauth1_client_secret;
-  GtkWidget *oauth1_get_access_token;
-  RestProxy *oauth1_proxy;
-
   /* oauth 2 auth */
   GtkWidget *oauth2_client_identifier;
   GtkWidget *oauth2_client_secret;
@@ -73,7 +67,6 @@ typedef enum {
   AUTHMODE_NO,
   AUTHMODE_BASIC,
   AUTHMODE_DIGEST,
-  AUTHMODE_OAUTH1,
   AUTHMODE_OAUTH2
 } AuthMode;
 
@@ -90,7 +83,6 @@ demo_rest_page_finalize (GObject *object)
 {
   DemoRestPage *self = (DemoRestPage *)object;
 
-  g_clear_object (&self->oauth1_proxy);
   g_clear_object (&self->oauth2_proxy);
   g_clear_pointer (&self->pkce, rest_pkce_code_challenge_free);
 
@@ -111,8 +103,6 @@ get_current_auth_mode (DemoRestPage *self)
     return AUTHMODE_BASIC;
   else if (g_strcmp0 (stack_name, "digest") == 0)
     return AUTHMODE_DIGEST;
-  else if (g_strcmp0 (stack_name, "oauth1") == 0)
-    return AUTHMODE_OAUTH1;
   else if (g_strcmp0 (stack_name, "oauth2") == 0)
     return AUTHMODE_OAUTH2;
 
@@ -135,9 +125,7 @@ set_oauth_btn_active (DemoRestPage *self,
     {
       gtk_button_set_label (btn, "Get access token...");
       gtk_widget_set_css_classes (GTK_WIDGET (btn), (const char*[]){ "suggested-action", NULL });
-      if (proxy == self->oauth1_proxy)
-        g_clear_object (&self->oauth1_proxy);
-      else if (proxy == self->oauth2_proxy)
+      if (proxy == self->oauth2_proxy)
         g_clear_object (&self->oauth2_proxy);
     }
 }
@@ -195,23 +183,6 @@ set_text_response (DemoRestPage  *self,
   gtk_notebook_set_current_page (GTK_NOTEBOOK (self->notebook), 0);
 }
 
-static void
-demo_rest_page_fetched_oauth1_access_token (GObject      *object,
-                                            GAsyncResult *result,
-                                            gpointer      user_data)
-{
-  DemoRestPage *self = (DemoRestPage *)user_data;
-  RestProxy *proxy = (RestProxy *)object;
-  g_autoptr(GError) error = NULL;
-
-  g_assert (G_IS_OBJECT (object));
-  g_assert (G_IS_ASYNC_RESULT (result));
-
-  oauth_proxy_access_token_finish (OAUTH_PROXY (proxy), result, &error);
-  if (error)
-    set_oauth_btn_active (self, GTK_BUTTON (self->oauth1_get_access_token), proxy, FALSE);
-}
-
 static void
 demo_rest_page_fetched_oauth2_access_token (GObject      *object,
                                             GAsyncResult *result,
@@ -231,35 +202,6 @@ demo_rest_page_fetched_oauth2_access_token (GObject      *object,
     }
 }
 
-static void
-oauth1_dialog_response (GtkDialog    *dialog,
-                        gint          response_id,
-                        DemoRestPage *self)
-{
-  switch (response_id)
-    {
-    case GTK_RESPONSE_OK:
-      {
-        const gchar *verifier = NULL;
-        GtkWidget *content_area = gtk_dialog_get_content_area (dialog);
-        GtkWidget *box = gtk_widget_get_first_child (content_area);
-        GtkWidget *entry = gtk_widget_get_last_child (box);
-
-        verifier = gtk_editable_get_text (GTK_EDITABLE (entry));
-        oauth_proxy_access_token_async (OAUTH_PROXY (self->oauth1_proxy),
-                                        "access_token",
-                                        verifier,
-                                        NULL,
-                                        demo_rest_page_fetched_oauth1_access_token,
-                                        self);
-        break;
-      }
-    case GTK_RESPONSE_CANCEL:
-      set_oauth_btn_active (self, GTK_BUTTON (self->oauth1_get_access_token), self->oauth1_proxy, FALSE);
-      break;
-    }
-}
-
 static void
 oauth2_dialog_response (GtkDialog    *dialog,
                         gint          response_id,
@@ -289,48 +231,6 @@ oauth2_dialog_response (GtkDialog    *dialog,
     }
 }
 
-static GtkWidget *
-demo_rest_page_create_oauth1_dialog (DemoRestPage *self,
-                                     RestProxy    *proxy)
-{
-  GtkWidget *dialog = NULL;
-  GtkWidget *content_area;
-  GtkWidget *box, *lbl, *token_lbl, *verifier_entry;
-  g_autofree char *token_str = NULL;
-
-  dialog = gtk_dialog_new_with_buttons ("Get Verifier...",
-                                        GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
-                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | 
GTK_DIALOG_USE_HEADER_BAR,
-                                        "Ok",
-                                        GTK_RESPONSE_OK,
-                                        "Cancel",
-                                        GTK_RESPONSE_CANCEL,
-                                        NULL);
-
-  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-  gtk_widget_set_margin_top (content_area, 6);
-  gtk_widget_set_margin_start (content_area, 6);
-  gtk_widget_set_margin_bottom (content_area, 6);
-  gtk_widget_set_margin_end (content_area, 6);
-
-  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-  lbl = gtk_label_new ("Open a browser and authorize this application...");
-  gtk_box_append (GTK_BOX (box), lbl);
-  token_str = g_strdup_printf ("Use this token: %s", oauth_proxy_get_token (OAUTH_PROXY (proxy)));
-  token_lbl = gtk_label_new (token_str);
-  gtk_label_set_selectable (GTK_LABEL (token_lbl), TRUE);
-  gtk_box_append (GTK_BOX (box), token_lbl);
-  verifier_entry = gtk_entry_new ();
-  gtk_box_append (GTK_BOX (box), verifier_entry);
-
-  gtk_box_append (GTK_BOX (content_area), box);
-
-  g_signal_connect (dialog, "response", G_CALLBACK (oauth1_dialog_response), self);
-  g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_window_destroy), dialog);
-
-  return dialog;
-}
-
 static GtkWidget *
 demo_rest_page_create_oauth2_dialog (DemoRestPage *self,
                                      RestProxy    *proxy)
@@ -377,57 +277,6 @@ demo_rest_page_create_oauth2_dialog (DemoRestPage *self,
   return dialog;
 }
 
-static void
-demo_rest_page_fetched_oauth1_request_token (GObject      *object,
-                                             GAsyncResult *result,
-                                             gpointer      user_data)
-{
-  DemoRestPage *self = (DemoRestPage *)user_data;
-  RestProxy *proxy = (RestProxy *)object;
-  GtkWidget *dialog = NULL;
-  g_autoptr(GError) error = NULL;
-
-  g_assert (G_IS_OBJECT (object));
-  g_assert (G_IS_ASYNC_RESULT (result));
-
-  oauth_proxy_request_token_finish (OAUTH_PROXY (proxy), result, &error);
-  if (error)
-    {
-      set_oauth_btn_active (self, GTK_BUTTON (self->oauth1_get_access_token), proxy, FALSE);
-      return;
-    }
-
-  /* here we show a dialog requesting the user to a browser for authentication */
-  dialog = demo_rest_page_create_oauth1_dialog (self, proxy);
-
-  gtk_widget_show (dialog);
-}
-
-static void
-on_oauth1_get_access_token_clicked (GtkButton *btn,
-                                    gpointer   user_data)
-{
-  DemoRestPage *self = (DemoRestPage *)user_data;
-  const char *url = NULL;
-  const char *consumer_key = NULL, *consumer_secret = NULL;
-  const char *function = NULL;
-
-  if (self->oauth1_proxy != NULL)
-    {
-      set_oauth_btn_active (self, btn, self->oauth1_proxy, FALSE);
-      return;
-    }
-
-  url = gtk_editable_get_text (GTK_EDITABLE (self->host));
-  consumer_key = gtk_editable_get_text (GTK_EDITABLE (self->oauth1_client_identifier));
-  consumer_secret = gtk_editable_get_text (GTK_EDITABLE (self->oauth1_client_secret));
-  function = gtk_editable_get_text (GTK_EDITABLE (self->function));
-
-  self->oauth1_proxy = oauth_proxy_new (consumer_key, consumer_secret, url, FALSE);
-  oauth_proxy_request_token_async (OAUTH_PROXY (self->oauth1_proxy), function, "https://www.gnome.org";, 
NULL, demo_rest_page_fetched_oauth1_request_token, self);
-  set_oauth_btn_active (self, btn, self->oauth1_proxy, TRUE);
-}
-
 static void
 on_oauth2_get_access_token_clicked (GtkButton *btn,
                                     gpointer   user_data)
@@ -531,13 +380,6 @@ on_send_clicked (GtkButton *btn,
         password = gtk_editable_get_text (GTK_EDITABLE (self->basic_password));
 
         proxy = rest_proxy_new_with_authentication (url, FALSE, username, password);
-        break;
-      }
-    case AUTHMODE_OAUTH1:
-      {
-        g_object_set (self->oauth1_proxy, "url-format", url, NULL);
-        proxy = self->oauth1_proxy;
-
         break;
       }
     case AUTHMODE_OAUTH2:
@@ -620,10 +462,6 @@ demo_rest_page_class_init (DemoRestPageClass *klass)
   /* digest auth */
   gtk_widget_class_bind_template_child (widget_class, DemoRestPage, digest_username);
   gtk_widget_class_bind_template_child (widget_class, DemoRestPage, digest_password);
-  /* oauth 1 auth */
-  gtk_widget_class_bind_template_child (widget_class, DemoRestPage, oauth1_client_identifier);
-  gtk_widget_class_bind_template_child (widget_class, DemoRestPage, oauth1_client_secret);
-  gtk_widget_class_bind_template_child (widget_class, DemoRestPage, oauth1_get_access_token);
   /* oauth 2 auth */
   gtk_widget_class_bind_template_child (widget_class, DemoRestPage, oauth2_client_identifier);
   gtk_widget_class_bind_template_child (widget_class, DemoRestPage, oauth2_client_secret);
@@ -635,7 +473,6 @@ demo_rest_page_class_init (DemoRestPageClass *klass)
   /* callbacks */
   gtk_widget_class_bind_template_callback (widget_class, on_send_clicked);
   gtk_widget_class_bind_template_callback (widget_class, on_auth_method_activated);
-  gtk_widget_class_bind_template_callback (widget_class, on_oauth1_get_access_token_clicked);
   gtk_widget_class_bind_template_callback (widget_class, on_oauth2_get_access_token_clicked);
 }
 
diff --git a/examples/demo/demo-rest-page.ui b/examples/demo/demo-rest-page.ui
index a5771c8..3bfc004 100644
--- a/examples/demo/demo-rest-page.ui
+++ b/examples/demo/demo-rest-page.ui
@@ -81,7 +81,6 @@
                       <item>No Auth</item>
                       <item>Basic</item>
                       <item>Digest</item>
-                      <item>OAuth1</item>
                       <item>OAuth2</item>
                     </items>
                   </object>
@@ -197,78 +196,6 @@
                     </property>
                   </object>
                 </child>
-                <child>
-                  <object class="GtkStackPage">
-                    <property name="name">oauth1</property>
-                    <property name="child">
-                      <object class="GtkGrid">
-                        <property name="column-spacing">8</property>
-                        <property name="row-spacing">6</property>
-                        <child>
-                          <object class="GtkLabel">
-                            <property name="hexpand">true</property>
-                            <property name="label">Client Identifier:</property>
-                            <property name="xalign">1.0</property>
-                            <layout>
-                              <property name="column">0</property>
-                              <property name="row">0</property>
-                            </layout>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="oauth1_client_identifier">
-                            <property name="hexpand">true</property>
-                            <layout>
-                              <property name="column">1</property>
-                              <property name="row">0</property>
-                            </layout>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkImage">
-                            <property name="icon-name">dialog-question-symbolic</property>
-                            <property name="tooltip-text">Typically the consumer key and secret can be 
obtained from the oauth provider.</property>
-                            <layout>
-                              <property name="column">2</property>
-                              <property name="row">0</property>
-                            </layout>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkLabel">
-                            <property name="label">Client Secret:</property>
-                            <property name="xalign">1.0</property>
-                            <layout>
-                              <property name="column">0</property>
-                              <property name="row">1</property>
-                            </layout>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="oauth1_client_secret">
-                            <layout>
-                              <property name="column">1</property>
-                              <property name="row">1</property>
-                            </layout>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkButton" id="oauth1_get_access_token">
-                            <property name="label">Get access token...</property>
-                            <layout>
-                              <property name="column">1</property>
-                              <property name="row">2</property>
-                            </layout>
-                            <signal name="clicked" handler="on_oauth1_get_access_token_clicked" swapped="no" 
object="DemoRestPage"/>
-                            <style>
-                              <class name="suggested-action"/>
-                            </style>
-                          </object>
-                        </child>
-                      </object>
-                    </property>
-                  </object>
-                </child>
                 <child>
                   <object class="GtkStackPage">
                     <property name="name">oauth2</property>
diff --git a/examples/meson.build b/examples/meson.build
index 37ea0ca..34c8f33 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -2,11 +2,8 @@ example_names = [
   'test-raw',
   'test-xml',
   'dump-xml',
-  'post-twitter',
-  'post-twitter-media',
   'get-flickr-favorites',
   'lastfm-shout',
-  'continuous-twitter',
   'gitlab-oauth2-example',
 ]
 
diff --git a/rest/meson.build b/rest/meson.build
index 545221b..0a16c36 100644
--- a/rest/meson.build
+++ b/rest/meson.build
@@ -17,8 +17,6 @@ librest_sources = [
   'rest-xml-node.c',
   'rest-xml-parser.c',
   'rest-main.c',
-  'oauth-proxy.c',
-  'oauth-proxy-call.c',
   'sha1.c',
 
   'rest-oauth2-proxy.c',
@@ -31,8 +29,6 @@ librest_sources = [
 ]
 
 librest_headers = [
-  'oauth-proxy-call.h',
-  'oauth-proxy.h',
   'rest-param.h',
   'rest-params.h',
   'rest-proxy-call.h',
@@ -119,20 +115,4 @@ librest_dep = declare_dependency(
   dependencies: librest_deps,
 )
 
-meson.override_dependency('rest-1.0', librest_dep)
-
-# Test suite
-test_runner_c_args = [
-  '-DBUILD_TESTS',
-]
-
-test_runner_bin = executable('test-runner',
-  [ 'test-runner.c', librest_sources ],
-  dependencies: librest_deps,
-  c_args: test_runner_c_args,
-  include_directories: config_h_inc,
-)
-
-test('test-runner', test_runner_bin,
-  suite: 'rest',
-)
+meson.override_dependency('rest-1.0', librest_dep)
\ No newline at end of file
diff --git a/rest/rest.h b/rest/rest.h
index 2db9eb7..0c4afbb 100644
--- a/rest/rest.h
+++ b/rest/rest.h
@@ -27,8 +27,6 @@ G_BEGIN_DECLS
 #define REST_INSIDE
 # include "rest-proxy.h"
 # include "rest-proxy-call.h"
-# include "oauth-proxy.h"
-# include "oauth-proxy-call.h"
 # include "rest-oauth2-proxy.h"
 # include "rest-utils.h"
 # include "rest-pkce-code-challenge.h"


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