[evolution-data-server] Bug #703181 - Book/calendar backends can authenticate without password
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #703181 - Book/calendar backends can authenticate without password
- Date: Fri, 16 Aug 2013 14:19:13 +0000 (UTC)
commit b4c00af15f6fb255475cbde134b6265b4f4688a2
Author: Milan Crha <mcrha redhat com>
Date: Fri Aug 16 16:17:53 2013 +0200
Bug #703181 - Book/calendar backends can authenticate without password
configure.ac | 4 +-
libebackend/e-authentication-mediator.c | 20 ++++++++---
libebackend/e-authentication-session.c | 26 ++++++++++++++
libedataserver/e-source-authenticator.c | 35 ++++++++++++++++++++
libedataserver/e-source-authenticator.h | 4 ++
libedataserver/e-source-registry.c | 2 +
...rg.gnome.evolution.dataserver.Authenticator.xml | 3 ++
7 files changed, 86 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4bae0c9..36d5c17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,7 +106,7 @@ AC_SUBST(USER_PROMPTER_DBUS_SERVICE_NAME)
dnl ******************************
dnl Libtool versioning
dnl ******************************
-LIBEDATASERVER_CURRENT=17
+LIBEDATASERVER_CURRENT=18
LIBEDATASERVER_REVISION=0
LIBEDATASERVER_AGE=0
@@ -134,7 +134,7 @@ LIBCAMEL_CURRENT=44
LIBCAMEL_REVISION=0
LIBCAMEL_AGE=0
-LIBEBACKEND_CURRENT=6
+LIBEBACKEND_CURRENT=7
LIBEBACKEND_REVISION=0
LIBEBACKEND_AGE=0
diff --git a/libebackend/e-authentication-mediator.c b/libebackend/e-authentication-mediator.c
index fa64bd5..2a571bb 100644
--- a/libebackend/e-authentication-mediator.c
+++ b/libebackend/e-authentication-mediator.c
@@ -774,6 +774,16 @@ authentication_mediator_initable_init (GInitable *initable,
return TRUE;
}
+static gboolean
+authentication_mediator_get_without_password (ESourceAuthenticator *auth)
+{
+ EAuthenticationMediator *mediator;
+
+ mediator = E_AUTHENTICATION_MEDIATOR (auth);
+
+ return e_dbus_authenticator_get_without_password (mediator->priv->interface);
+}
+
static ESourceAuthenticationResult
authentication_mediator_try_password_sync (ESourceAuthenticator *auth,
const GString *password,
@@ -959,12 +969,10 @@ e_authentication_mediator_initable_init (GInitableIface *interface)
static void
e_authentication_mediator_interface_init (ESourceAuthenticatorInterface *interface)
{
- interface->try_password_sync =
- authentication_mediator_try_password_sync;
- interface->try_password =
- authentication_mediator_try_password;
- interface->try_password_finish =
- authentication_mediator_try_password_finish;
+ interface->get_without_password = authentication_mediator_get_without_password;
+ interface->try_password_sync = authentication_mediator_try_password_sync;
+ interface->try_password = authentication_mediator_try_password;
+ interface->try_password_finish = authentication_mediator_try_password_finish;
}
static void
diff --git a/libebackend/e-authentication-session.c b/libebackend/e-authentication-session.c
index bd4eb66..3d71b2e 100644
--- a/libebackend/e-authentication-session.c
+++ b/libebackend/e-authentication-session.c
@@ -435,6 +435,32 @@ authentication_session_execute_sync (EAuthenticationSession *session,
source_uid = e_authentication_session_get_source_uid (session);
authenticator = e_authentication_session_get_authenticator (session);
+ if (e_source_authenticator_get_without_password (authenticator)) {
+ password_string = g_string_new ("");
+
+ auth_result = e_source_authenticator_try_password_sync (
+ authenticator, password_string, cancellable, &local_error);
+
+ g_string_free (password_string, TRUE);
+ password_string = NULL;
+
+ if (auth_result == E_SOURCE_AUTHENTICATION_ERROR &&
+ g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_propagate_error (error, local_error);
+ session_result = E_AUTHENTICATION_SESSION_ERROR;
+ goto exit;
+ }
+
+ g_clear_error (&local_error);
+
+ if (auth_result == E_SOURCE_AUTHENTICATION_ACCEPTED) {
+ session_result = E_AUTHENTICATION_SESSION_SUCCESS;
+ goto exit;
+ }
+
+ /* if an empty password fails, then ask a user for it */
+ }
+
success = e_authentication_session_lookup_password_sync (
session, cancellable, &stored_password, error);
diff --git a/libedataserver/e-source-authenticator.c b/libedataserver/e-source-authenticator.c
index 4985724..02bb8c1 100644
--- a/libedataserver/e-source-authenticator.c
+++ b/libedataserver/e-source-authenticator.c
@@ -246,6 +246,13 @@ source_authenticator_get_prompt_strings (ESourceAuthenticator *auth,
g_free (user_name);
}
+static gboolean
+source_authenticator_get_without_password (ESourceAuthenticator *auth)
+{
+ /* require password by default */
+ return FALSE;
+}
+
/* Helper for source_authenticator_try_password() */
static void
source_authenticator_try_password_thread (GSimpleAsyncResult *simple,
@@ -323,6 +330,7 @@ static void
e_source_authenticator_default_init (ESourceAuthenticatorInterface *interface)
{
interface->get_prompt_strings = source_authenticator_get_prompt_strings;
+ interface->get_without_password = source_authenticator_get_without_password;
interface->try_password = source_authenticator_try_password;
interface->try_password_finish = source_authenticator_try_password_finish;
}
@@ -377,6 +385,33 @@ e_source_authenticator_get_prompt_strings (ESourceAuthenticator *auth,
}
/**
+ * e_source_authenticator_get_without_password:
+ * @auth: an #ESourceAuthenticator
+ *
+ * Returns whether the used authentication method can be used without
+ * a password prompt. If so, then user is not asked for the password,
+ * only if the authentication fails. The default implementation returns
+ * #FALSE, which means always asks for the password (or read it from
+ * a keyring).
+ *
+ * Returns: Whether may try to authenticate without asking for the password.
+ *
+ * Since: 3.10
+ **/
+gboolean
+e_source_authenticator_get_without_password (ESourceAuthenticator *auth)
+{
+ ESourceAuthenticatorInterface *interface;
+
+ g_return_val_if_fail (E_IS_SOURCE_AUTHENTICATOR (auth), FALSE);
+
+ interface = E_SOURCE_AUTHENTICATOR_GET_INTERFACE (auth);
+ g_return_val_if_fail (interface->get_without_password, FALSE);
+
+ return interface->get_without_password (auth);
+}
+
+/**
* e_source_authenticator_try_password_sync:
* @auth: an #ESourceAuthenticator
* @password: a user-provided password
diff --git a/libedataserver/e-source-authenticator.h b/libedataserver/e-source-authenticator.h
index a380599..977f8f7 100644
--- a/libedataserver/e-source-authenticator.h
+++ b/libedataserver/e-source-authenticator.h
@@ -63,6 +63,8 @@ struct _ESourceAuthenticatorInterface {
gchar **prompt_message,
gchar **prompt_description);
+ gboolean (*get_without_password) (ESourceAuthenticator *auth);
+
/* Synchronous I/O Methods */
ESourceAuthenticationResult
(*try_password_sync) (ESourceAuthenticator *auth,
@@ -89,6 +91,8 @@ void e_source_authenticator_get_prompt_strings
gchar **prompt_title,
gchar **prompt_message,
gchar **prompt_description);
+gboolean e_source_authenticator_get_without_password
+ (ESourceAuthenticator *auth);
ESourceAuthenticationResult
e_source_authenticator_try_password_sync
(ESourceAuthenticator *auth,
diff --git a/libedataserver/e-source-registry.c b/libedataserver/e-source-registry.c
index 9e433f7..70c99bb 100644
--- a/libedataserver/e-source-registry.c
+++ b/libedataserver/e-source-registry.c
@@ -2037,6 +2037,8 @@ e_source_registry_authenticate_sync (ESourceRegistry *registry,
if (local_error != NULL)
goto exit;
+ e_dbus_authenticator_set_without_password (dbus_auth, e_source_authenticator_get_without_password
(auth));
+
auth_context = g_slice_new0 (AuthContext);
auth_context->auth = g_object_ref (auth);
auth_context->dbus_auth = dbus_auth; /* takes ownership */
diff --git a/private/org.gnome.evolution.dataserver.Authenticator.xml
b/private/org.gnome.evolution.dataserver.Authenticator.xml
index 195e73a..4a17fb4 100644
--- a/private/org.gnome.evolution.dataserver.Authenticator.xml
+++ b/private/org.gnome.evolution.dataserver.Authenticator.xml
@@ -10,6 +10,9 @@
Interface for an authentication session.
-->
<interface name="org.gnome.evolution.dataserver.Authenticator">
+ <!-- WithoutPassword: Whether to try to authenticate without a password first. -->
+ <property name="WithoutPassword" type="b" access="readwrite"/>
+
<!--
Ready:
@encryption_key: Implementation defined encryption key
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]