summaryrefslogtreecommitdiff
path: root/src/goabackend/goaoauth2provider.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/goabackend/goaoauth2provider.c')
-rw-r--r--src/goabackend/goaoauth2provider.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c
index 41a8a0d6..d4ca09c9 100644
--- a/src/goabackend/goaoauth2provider.c
+++ b/src/goabackend/goaoauth2provider.c
@@ -826,13 +826,23 @@ parse_request_uri (GoaOAuth2Provider *self,
AccountData *data = g_task_get_task_data (task);
g_autoptr(GHashTable) key_value_pairs = NULL;
g_autoptr(GUri) uri = NULL;
+ g_autoptr(GUri) redirect_uri = NULL;
const char *fragment;
const char *oauth2_error;
const char *query;
g_assert (error == NULL || *error == NULL);
- if (!g_str_has_prefix (requested_uri, data->redirect_uri))
+ uri = g_uri_parse (requested_uri, G_URI_FLAGS_ENCODED | G_URI_FLAGS_PARSE_RELAXED, error);
+ if (uri == NULL)
+ return FALSE;
+
+ redirect_uri = g_uri_parse (data->redirect_uri, G_URI_FLAGS_ENCODED | G_URI_FLAGS_PARSE_RELAXED, error);
+ if (redirect_uri == NULL)
+ return FALSE;
+
+ if (g_strcmp0 (g_uri_get_scheme (uri), g_uri_get_scheme (redirect_uri)) != 0
+ || g_strcmp0 (g_uri_get_path (uri), g_uri_get_path (redirect_uri)) != 0)
{
g_set_error (error,
GOA_ERROR,
@@ -842,10 +852,6 @@ parse_request_uri (GoaOAuth2Provider *self,
return FALSE;
}
- uri = g_uri_parse (requested_uri, G_URI_FLAGS_ENCODED | G_URI_FLAGS_PARSE_RELAXED, error);
- if (uri == NULL)
- return FALSE;
-
/* Three cases:
* 1) we can either have the backend handle the URI for us, or
* 2) we can either have the access_token and other information
@@ -1166,6 +1172,7 @@ oauth2_handler_dbus_method_call (GDBusConnection *connection,
g_debug ("Received OAuth2 response for client ID \"%s\"", client_id);
g_dbus_method_invocation_return_value (invocation, NULL);
+ authorize_uri_task_complete (NULL, task);
g_task_return_pointer (task, g_strdup (response), g_free);
}
else
@@ -1177,10 +1184,10 @@ oauth2_handler_dbus_method_call (GDBusConnection *connection,
G_DBUS_ERROR_INVALID_ARGS,
"Invalid URI \"%s\"",
response);
+ authorize_uri_task_complete (NULL, task);
g_task_return_error (task, g_steal_pointer (&error));
}
- authorize_uri_task_complete (NULL, task);
return;
}
@@ -1209,8 +1216,8 @@ authorize_uri_launch_uri_cb (GObject *object,
if (!g_app_info_launch_default_for_uri_finish (result, &error))
{
- g_task_return_error (task, g_steal_pointer (&error));
authorize_uri_task_complete (NULL, task);
+ g_task_return_error (task, g_steal_pointer (&error));
}
}
@@ -1242,8 +1249,8 @@ on_oauth2_bus_acquired (GDBusConnection *connection,
if (data->register_object_id == 0)
{
- g_task_return_error (task, g_steal_pointer (&error));
authorize_uri_task_complete (NULL, task);
+ g_task_return_error (task, g_steal_pointer (&error));
}
}
@@ -1278,11 +1285,11 @@ on_oauth2_name_lost (GDBusConnection *connection,
else
g_warning ("%s(): Failed to own %s on the session bus", G_STRFUNC, name);
+ authorize_uri_task_complete (NULL, task);
g_task_return_new_error_literal (task,
GOA_ERROR,
GOA_ERROR_FAILED,
_("Service not available"));
- authorize_uri_task_complete (NULL, task);
}
/* ---------------------------------------------------------------------------------------------------- */