anastasis-gtk

Demonstrator GUI for Anastasis
Log | Files | Refs | README | LICENSE

commit ffed49158f45ec109fea89095de918ef489ac29b
parent 3b5809bcf0c071eaaaeaee2a15e2b87c32202235
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 26 Sep 2021 16:18:46 +0200

integrate multifactor warn dialog into flow

Diffstat:
Mcontrib/anastasis_gtk_warn_multifactor.glade | 1-
Msrc/anastasis/anastasis-gtk_action.c | 8++++----
Msrc/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 95 insertions(+), 7 deletions(-)

diff --git a/contrib/anastasis_gtk_warn_multifactor.glade b/contrib/anastasis_gtk_warn_multifactor.glade @@ -11,7 +11,6 @@ <property name="message-type">warning</property> <property name="text" translatable="yes">To keep your secret secure, we recommend you specify at least three authentication options before proceeding.</property> <property name="secondary-text" translatable="yes">Select "back" to add additional authentication options.</property> - <signal name="close" handler="anastasis_gtk_confirm_multifactor_dialog_close_cb" swapped="no"/> <signal name="response" handler="anastasis_gtk_confirm_multifactor_dialog_response_cb" swapped="no"/> <child internal-child="vbox"> <object class="GtkBox"> diff --git a/src/anastasis/anastasis-gtk_action.c b/src/anastasis/anastasis-gtk_action.c @@ -3056,11 +3056,11 @@ action_challenge_solving (void) /* show dialog */ { GtkWidget *toplevel; - GtkBox *box; + GtkWidget *box; - box = GTK_BOX (GCG_get_main_window_object ( - "anastasis_gtk_open_challenge_box")); - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (box)); + box = GTK_WIDGET (GCG_get_main_window_object ( + "anastasis_gtk_open_challenge_box")); + toplevel = gtk_widget_get_toplevel (box); gtk_window_set_transient_for (GTK_WINDOW (diag), GTK_WINDOW (toplevel)); gtk_window_present (GTK_WINDOW (diag)); diff --git a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c @@ -137,12 +137,97 @@ AG_forward_user_attributes_collecting (void) } +/** + * Function called with the result of questioning the user + * if they really want to proceed with less than three + * authentication factors. + * + * @param the dialog + * @param response_id must be GTK_RESPONSE_OK to proceed + * @param user_data the builder + */ +void +anastasis_gtk_confirm_multifactor_dialog_response_cb ( + GtkDialog *dialog, + gint response_id, + gpointer user_data) +{ + GtkBuilder *builder = user_data; + + gtk_widget_destroy (GTK_WIDGET (dialog)); + g_object_unref (G_OBJECT (builder)); + if (GTK_RESPONSE_OK != response_id) + { + AG_thaw (); + return; + } + AG_ra = ANASTASIS_redux_action (AG_redux_state, + "next", + NULL, + &AG_action_cb, + NULL); +} + + +/** + * Launch dialog to question sanity of user providing + * too few authentication methods. + */ +static void +question_sanity (void) +{ + GtkBuilder *builder; + GtkDialog *ad; + + builder = GNUNET_GTK_get_new_builder ( + "anastasis_gtk_warn_multifactor.glade", + NULL); + if (NULL == builder) + { + GNUNET_break (0); + return; + } + ad = GTK_DIALOG (gtk_builder_get_object (builder, + "anastasis_gtk_confirm_multifactor_dialog")); + if (NULL == ad) + { + GNUNET_break (0); + g_object_unref (G_OBJECT (builder)); + return; + } + /* show dialog */ + { + GtkWidget *toplevel; + GtkWidget *widget; + + widget = GTK_WIDGET (GCG_get_main_window_object ( + "anastasis_gtk_open_challenge_box")); + toplevel = gtk_widget_get_toplevel (widget); + gtk_window_set_transient_for (GTK_WINDOW (ad), + GTK_WINDOW (toplevel)); + gtk_window_present (GTK_WINDOW (ad)); + } +} + + +/** + * The user has clicked 'next' in the 'authentications_editing' state. + * Check if the number of authentication methods configured is above + * a threshold. If no, warn before allowing to proceed. + */ static void forward_authentications_editing (void) { + json_t *methods; + AG_freeze (); - // FIXME: if insufficient authentication methods, - // throw warning at the user! + methods = json_object_get (AG_redux_state, + "authentication_methods"); + if (json_array_size (methods) < 3) + { + question_sanity (); + return; + } AG_ra = ANASTASIS_redux_action (AG_redux_state, "next", NULL, @@ -151,6 +236,10 @@ forward_authentications_editing (void) } +/** + * The user has pressed 'next' in POLICIES_EDITING state. + * Proceed to secret editing. + */ static void forward_policies_reviewing (void) {