From: Daniel Carl Date: Tue, 31 Jan 2017 23:33:22 +0000 (+0100) Subject: Added real auth observer to webextension too. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=a825ba97de3af8d315b79717dad4cdafe9ab5d00;p=vimb.git Added real auth observer to webextension too. --- diff --git a/src/Makefile b/src/Makefile index ddf3d15..b1bd8be 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,8 +9,7 @@ clean: $(RM) vimb *.o vimb: $(OBJ) - @echo "$(CC) $@" - $(CC) $(LDFLAGS) $(OBJ) -o $@ + $(CC) $(LDFLAGS) $^ -o $@ $(OBJ): config.h $(BASEDIR)/config.mk diff --git a/src/webextension/ext-main.c b/src/webextension/ext-main.c index cfc8e01..f2d5d75 100644 --- a/src/webextension/ext-main.c +++ b/src/webextension/ext-main.c @@ -115,8 +115,23 @@ void webkit_web_extension_initialize_with_user_data(WebKitWebExtension *extensio static gboolean on_authorize_authenticated_peer(GDBusAuthObserver *observer, GIOStream *stream, GCredentials *credentials, gpointer extension) { - /* FIXME require authentication logic */ - return TRUE; + static GCredentials *own_credentials = NULL; + GError *error = NULL; + + if (!own_credentials) { + own_credentials = g_credentials_new(); + } + + if (credentials && g_credentials_is_same_user(credentials, own_credentials, &error)) { + return TRUE; + } + + if (error) { + g_warning("Failed to authorize connection to ui: %s", error->message); + g_error_free(error); + } + + return FALSE; } static void on_dbus_connection_created(GObject *source_object, @@ -126,6 +141,7 @@ static void on_dbus_connection_created(GObject *source_object, GDBusConnection *connection; GError *error = NULL; + g_message("on_dbus_connection_created"); if (!node_info) { node_info = g_dbus_node_info_new_for_xml(introspection_xml, NULL); }