gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis-gtk] branch master updated: add dialog to answer TOTP c


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: add dialog to answer TOTP challenges
Date: Sun, 26 Sep 2021 15:52:48 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis-gtk.

The following commit(s) were added to refs/heads/master by this push:
     new 3b5809b  add dialog to answer TOTP challenges
3b5809b is described below

commit 3b5809bcf0c071eaaaeaee2a15e2b87c32202235
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Sep 26 15:52:46 2021 +0200

    add dialog to answer TOTP challenges
---
 contrib/Makefile.am                        |   1 +
 contrib/anastasis_gtk_challenge_totp.glade | 233 +++++++++++++++++++++++++++++
 src/anastasis/anastasis-gtk_action.c       |  73 ++++++++-
 3 files changed, 305 insertions(+), 2 deletions(-)

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 2ef1d17..8e0862d 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -36,6 +36,7 @@ pkgdata_DATA = \
   anastasis_gtk_challenge_code.glade \
   anastasis_gtk_challenge_iban.glade \
   anastasis_gtk_challenge_question.glade \
+  anastasis_gtk_challenge_totp.glade \
   anastasis_gtk_edit_providers.glade \
   anastasis_gtk_edit_policy.glade \
   anastasis_gtk_open_file_dialog.glade \
diff --git a/contrib/anastasis_gtk_challenge_totp.glade 
b/contrib/anastasis_gtk_challenge_totp.glade
new file mode 100644
index 0000000..41daca4
--- /dev/null
+++ b/contrib/anastasis_gtk_challenge_totp.glade
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+Copyright (C) 2019-2021 Anastasis SARL
+
+This file is part of anastasis-gtk.
+
+anastasis-gtk is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+anastasis-gtk is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with anastasis-gtk.  If not, see <http://www.gnu.org/licenses/>.
+
+Author: Christian Grothoff
+
+-->
+<interface>
+  <requires lib="gtk+" version="3.6"/>
+  <!-- interface-license-type gplv3 -->
+  <!-- interface-name anastasis-gtk -->
+  <!-- interface-description key backup and recovery -->
+  <!-- interface-copyright 2019-2021 Anastasis SARL -->
+  <!-- interface-authors Christian Grothoff -->
+  <object class="GtkDialog" id="anastasis_gtk_c_totp_dialog">
+    <property name="can-focus">False</property>
+    <property name="type-hint">dialog</property>
+    <signal name="response" handler="anastasis_gtk_c_totp_dialog_response_cb" 
swapped="no"/>
+    <child internal-child="vbox">
+      <object class="GtkBox">
+        <property name="can-focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox">
+            <property name="can-focus">False</property>
+            <property name="layout-style">end</property>
+            <child>
+              <object class="GtkButton" 
id="anastasis_gtk_c_totp_dialog_btn_cancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-stock">True</property>
+                <property name="always-show-image">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" 
id="anastasis_gtk_c_totp_dialog_btn_ok">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can-focus">False</property>
+                <property name="receives-default">True</property>
+                <property name="use-stock">True</property>
+                <property name="always-show-image">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="anastasis_gtk_c_totp_error_label">
+            <property name="can-focus">False</property>
+            <property name="label">ERROR MESSAGE (SET DYNAMICALLY BY 
PROGRAM)</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+              <attribute name="foreground" value="#a5a51d1d2d2d"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">5</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkSeparator">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="label" translatable="yes">Please look up 
TOTP under:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="padding">5</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="challenge_instructions_label">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="label">SET DYNAMICALLY BY 
PROGRAM</property>
+                    <attributes>
+                      <attribute name="style" value="italic"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">5</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="label" translatable="yes">Enter the 
PIN:</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">5</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="anastasis_gtk_c_totp_entry">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="width-chars">24</property>
+                <property name="text">A-</property>
+                <property 
name="primary-icon-stock">gtk-dialog-authentication</property>
+                <property name="placeholder-text" 
translatable="yes">A-</property>
+                <signal name="changed" 
handler="anastasis_gtk_c_totp_dialog_answer_entry_changed_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">5</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">5</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget 
response="-6">anastasis_gtk_c_totp_dialog_btn_cancel</action-widget>
+      <action-widget 
response="-5">anastasis_gtk_c_totp_dialog_btn_ok</action-widget>
+    </action-widgets>
+    <child type="titlebar">
+      <object class="GtkLabel" id="anastasis_gtk_c_totp_dialog_label">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="label" translatable="yes">TOTP challenge</property>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget 
response="-6">anastasis_gtk_c_totp_dialog_btn_cancel</action-widget>
+      <action-widget 
response="-5">anastasis_gtk_c_totp_dialog_btn_ok</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index 5d4b461..87e06bc 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -2533,6 +2533,15 @@ action_challenge_paying (void)
  * Render challenge feedback for challenge @a uuid_str in a dialog of
  * @a builder in the label under @a target_widget.
  *
+ * Useful in case the operation previously failed at the
+ * server and we have some useful information to return
+ * to the user.
+ *
+ * FIXME: only do it AFTER the first attempt of the
+ * user to enter a code, and/or change what the
+ * server returns so we do NOT render a confusing
+ * error message on first use!
+ *
  * @param builder a builder to get widgets from
  * @param target_widget the widget to upate
  * @param uuid_str the UUID to render feedback for
@@ -2735,7 +2744,6 @@ diag_question (const json_t *details)
 
     uuid_str = json_string_value (json_object_get (details,
                                                    "uuid"));
-    /* Why do we do this? */
     render_feedback (builder,
                      "anastasis_gtk_c_question_error_label",
                      uuid_str);
@@ -2794,7 +2802,6 @@ diag_code (const json_t *details)
                                                
"anastasis_gtk_c_challenge_label"));
     gtk_label_set_text (label,
                         uuid_str);
-    /* Why do we do this? */
     render_feedback (builder,
                      "anastasis_gtk_c_code_error_label",
                      uuid_str);
@@ -2809,6 +2816,66 @@ diag_code (const json_t *details)
 }
 
 
+/**
+ * Create a dialog for the user to enter an TOTP code.
+ *
+ * @param details details about the dialog to render
+ * @return dialog object
+ */
+static GtkDialog *
+diag_totp (const json_t *details)
+{
+  GtkBuilder *builder;
+  const char *instructions;
+  const char *uuid_str;
+  struct GNUNET_JSON_Specification spec[] = {
+    GNUNET_JSON_spec_string ("instructions",
+                             &instructions),
+    GNUNET_JSON_spec_string ("uuid",
+                             &uuid_str),
+    GNUNET_JSON_spec_end ()
+  };
+
+  if (GNUNET_OK !=
+      GNUNET_JSON_parse (details,
+                         spec,
+                         NULL, NULL))
+  {
+    GNUNET_break (0);
+    json_dumpf (details,
+                stderr,
+                JSON_INDENT (2));
+    return NULL;
+  }
+
+  builder = GNUNET_GTK_get_new_builder ("anastasis_gtk_challenge_totp.glade",
+                                        NULL);
+  if (NULL == builder)
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
+  {
+    GtkLabel *label;
+
+    label = GTK_LABEL (gtk_builder_get_object (builder,
+                                               
"challenge_instructions_label"));
+    gtk_label_set_text (label,
+                        instructions);
+  }
+  render_feedback (builder,
+                   "anastasis_gtk_c_totp_error_label",
+                   uuid_str);
+  {
+    GtkDialog *ad;
+
+    ad = GTK_DIALOG (gtk_builder_get_object (builder,
+                                             "anastasis_gtk_c_totp_dialog"));
+    return ad;
+  }
+}
+
+
 /**
  * Create a dialog for the user to make an IBAN transfer.
  *
@@ -2941,6 +3008,8 @@ action_challenge_solving (void)
       .ctor = &diag_code },
     { .type = gettext_noop ("iban"),
       .ctor = &diag_iban },
+    { .type = gettext_noop ("totp"),
+      .ctor = &diag_totp },
     { .type = NULL,
       .ctor = NULL }
   };

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]