summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2014-09-02 16:23:32 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2014-09-03 12:17:29 +0200
commit4a9daa7faf47301915a60e2bef5da3d30a13827f (patch)
tree1becb702ca4e35e548339ec5c9a6d728d38d961d
parent5fdf8b176b59bdaef7fe36b6f6e02d863d261261 (diff)
oauth: Make sure RestProxyCall::url is set before using it
The oauth "prepare" step needs RestProxyCall::url to be set, but since commit c66b6d this is only set after the "prepare" and "serialize_headers" methods have been called. As it's better if OAuthProxyCall do not directly access RestProxyCall private data, this commit adds a getter to RestProxyCall which will be used to make sure RestProxyCall::url is set when OAuthProxyCall::prepare needs it. https://bugzilla.gnome.org/show_bug.cgi?id=708359 (cherry picked from commit 55f8e9626a50d81fb893508698205057668bf792)
-rw-r--r--rest/oauth-proxy-call.c6
-rw-r--r--rest/rest-proxy-call-private.h2
-rw-r--r--rest/rest-proxy-call.c11
3 files changed, 17 insertions, 2 deletions
diff --git a/rest/oauth-proxy-call.c b/rest/oauth-proxy-call.c
index d8cff95..42b63a0 100644
--- a/rest/oauth-proxy-call.c
+++ b/rest/oauth-proxy-call.c
@@ -119,12 +119,14 @@ sign_hmac (OAuthProxy *proxy, RestProxyCall *call, GHashTable *oauth_params)
{
OAuthProxyPrivate *priv;
RestProxyCallPrivate *callpriv;
+ const char *url_str;
char *key, *signature, *ep, *eep;
GString *text;
GHashTable *all_params;
priv = PROXY_GET_PRIVATE (proxy);
callpriv = call->priv;
+ url_str = rest_proxy_call_get_url (call);
text = g_string_new (NULL);
g_string_append (text, rest_proxy_call_get_method (REST_PROXY_CALL (call)));
@@ -132,7 +134,7 @@ sign_hmac (OAuthProxy *proxy, RestProxyCall *call, GHashTable *oauth_params)
if (priv->oauth_echo) {
g_string_append_uri_escaped (text, priv->service_url, NULL, FALSE);
} else if (priv->signature_host != NULL) {
- SoupURI *url = soup_uri_new (callpriv->url);
+ SoupURI *url = soup_uri_new (url_str);
gchar *signing_url;
soup_uri_set_host (url, priv->signature_host);
@@ -143,7 +145,7 @@ sign_hmac (OAuthProxy *proxy, RestProxyCall *call, GHashTable *oauth_params)
soup_uri_free (url);
g_free (signing_url);
} else {
- g_string_append_uri_escaped (text, callpriv->url, NULL, FALSE);
+ g_string_append_uri_escaped (text, url_str, NULL, FALSE);
}
g_string_append_c (text, '&');
diff --git a/rest/rest-proxy-call-private.h b/rest/rest-proxy-call-private.h
index ec7a4be..2647bb3 100644
--- a/rest/rest-proxy-call-private.h
+++ b/rest/rest-proxy-call-private.h
@@ -52,6 +52,8 @@ struct _RestProxyCallPrivate {
RestProxyCallAsyncClosure *cur_call_closure;
};
+const char *rest_proxy_call_get_url (RestProxyCall *call);
+
G_END_DECLS
#endif /* _REST_PROXY_CALL_PRIVATE */
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index 9c3c9f3..9bd2f7b 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -1592,3 +1592,14 @@ rest_proxy_call_serialize_params (RestProxyCall *call,
return FALSE;
}
+
+G_GNUC_INTERNAL const char *
+rest_proxy_call_get_url (RestProxyCall *call)
+{
+ /* Ensure priv::url is current before returning it. This method is used
+ * by OAuthProxyCall::_prepare which expects set_url() to have been called,
+ * but this has been changed/broken by c66b6df
+ */
+ set_url(call);
+ return call->priv->url;
+}