[gnome-online-accounts/gnome-3-24] flickr, oauth: Close the dialog if the user denied access



commit 9db20aca7dd0c14e7aa16322ec5fe4c4bd83b1f7
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Aug 8 17:50:15 2017 +0200

    flickr, oauth: Close the dialog if the user denied access
    
    ... via the OAuth1 web page.
    
    Ever since Flickr was added, clicking the "NO, THANKS" widget in the
    web page has redirected to https://www.gnome.org/, which is specified
    as GNOME's website in Flickr's App Garden, instead of to the specified
    callback URI and/or returning an error. The click on this element
    cannot be intercepted because the "click" event handler is not being
    called (WebKit bug?). Current attempts to inspect that element breaks
    the WebKit inspector.
    
    Instead, let's also use https://www.gnome.org/ as the callback URI,
    and use the lack of a query when redirecting to it to close the window.
    It might need adjustments when there is a different OAuth1-based
    provider.

 src/goabackend/goaflickrprovider.c |    6 +++++-
 src/goabackend/goaoauthprovider.c  |   25 ++++++++++++++++++-------
 2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/goabackend/goaflickrprovider.c b/src/goabackend/goaflickrprovider.c
index 5b6c906..0f68ecd 100644
--- a/src/goabackend/goaflickrprovider.c
+++ b/src/goabackend/goaflickrprovider.c
@@ -123,7 +123,11 @@ get_token_uri (GoaOAuthProvider *oauth_provider)
 static const gchar *
 get_callback_uri (GoaOAuthProvider *oauth_provider)
 {
-  return "https://www.gnome.org/goa-1.0/oauth";;
+  /* Should match the URI specified in the Flickr App
+   * Garden in order to detect when the user denied access via
+   * the OAuth1 web page.
+   */
+  return "https://www.gnome.org/";;
 }
 
 static const gchar *
diff --git a/src/goabackend/goaoauthprovider.c b/src/goabackend/goaoauthprovider.c
index b62a57f..2e02405 100644
--- a/src/goabackend/goaoauthprovider.c
+++ b/src/goabackend/goaoauthprovider.c
@@ -683,19 +683,30 @@ on_web_view_decide_policy (WebKitWebView            *web_view,
   uri = soup_uri_new (requested_uri);
   query = soup_uri_get_query (uri);
 
-  key_value_pairs = soup_form_decode (query);
+  if (query != NULL)
+    {
+      key_value_pairs = soup_form_decode (query);
+
+      data->oauth_verifier = g_strdup (g_hash_table_lookup (key_value_pairs, "oauth_verifier"));
+      if (data->oauth_verifier != NULL)
+        response_id = GTK_RESPONSE_OK;
+
+      g_hash_table_unref (key_value_pairs);
+    }
 
-  /* TODO: error handling? */
-  data->oauth_verifier = g_strdup (g_hash_table_lookup (key_value_pairs, "oauth_verifier"));
   if (data->oauth_verifier != NULL)
-    response_id = GTK_RESPONSE_OK;
+    goto ignore_request;
 
-  g_hash_table_unref (key_value_pairs);
+  /* TODO: The only OAuth1 provider is Flickr. It doesn't send any
+   * error code and only redirects to the URI specified in the Flickr
+   * App Garden. Re-evaluate when the situation changes.
+   */
+  response_id = GTK_RESPONSE_CANCEL;
   goto ignore_request;
 
  ignore_request:
-  if (response_id != GTK_RESPONSE_NONE)
-    gtk_dialog_response (data->dialog, response_id);
+  g_assert (response_id != GTK_RESPONSE_NONE);
+  gtk_dialog_response (data->dialog, response_id);
   webkit_policy_decision_ignore (decision);
   return TRUE;
 


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