[network-manager-fortisslvpn/lr/otp: 5/5] editor: add OTP support
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-fortisslvpn/lr/otp: 5/5] editor: add OTP support
- Date: Wed, 26 Jul 2017 16:08:12 +0000 (UTC)
commit 06b0043832d1f3c23a897670adb30de48316df3e
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Mon Jul 10 18:02:02 2017 +0200
editor: add OTP support
properties/nm-fortisslvpn-dialog.ui | 45 ++++++++++++++++++++++++++++++++--
properties/nm-fortisslvpn-editor.c | 25 ++++++++++++++++++-
2 files changed, 66 insertions(+), 4 deletions(-)
---
diff --git a/properties/nm-fortisslvpn-dialog.ui b/properties/nm-fortisslvpn-dialog.ui
index ef27a0d..c6e3848 100644
--- a/properties/nm-fortisslvpn-dialog.ui
+++ b/properties/nm-fortisslvpn-dialog.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.4"/>
<object class="GtkDialog" id="advanced_dialog">
@@ -64,6 +64,45 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Authentication</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkCheckButton" id="use_otp">
+ <property name="label" translatable="yes">Use a _one-time password</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Ask for an one-time password (OTP) for
two factor authentication (2FA).</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -76,7 +115,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -124,7 +163,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/properties/nm-fortisslvpn-editor.c b/properties/nm-fortisslvpn-editor.c
index e9066e5..3a344c8 100644
--- a/properties/nm-fortisslvpn-editor.c
+++ b/properties/nm-fortisslvpn-editor.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 Lubomir Rintel <lkundrak v3 sk>
+ * Copyright (C) 2015,2017 Lubomir Rintel <lkundrak v3 sk>
* Copyright (C) 2008 Dan Williams, <dcbw redhat com>
* Copyright (C) 2008 - 2011 Red Hat, Inc.
* Based on work by David Zeuthen, <davidz redhat com>
@@ -40,6 +40,7 @@ typedef struct {
gboolean window_added;
gboolean new_connection;
gchar *trusted_cert;
+ NMSettingSecretFlags otp_flags;
} FortisslvpnEditorPrivate;
static void fortisslvpn_editor_interface_init (NMVpnEditorInterface *iface_class);
@@ -172,14 +173,22 @@ advanced_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_dat
FortisslvpnEditor *self = FORTISSLVPN_EDITOR (user_data);
FortisslvpnEditorPrivate *priv = FORTISSLVPN_EDITOR_GET_PRIVATE (self);
GtkEntry *entry = GTK_ENTRY (gtk_builder_get_object (priv->builder, "trusted_cert_entry"));
+ GtkToggleButton *use_otp = GTK_TOGGLE_BUTTON (gtk_builder_get_object (priv->builder, "use_otp"));
g_assert (entry);
if (response == GTK_RESPONSE_OK) {
g_free (priv->trusted_cert);
priv->trusted_cert = g_strdup (gtk_entry_get_text (entry));
stuff_changed_cb (NULL, self);
+
+ if (gtk_toggle_button_get_active (use_otp))
+ priv->otp_flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED;
+ else
+ priv->otp_flags &= ~NM_SETTING_SECRET_FLAG_NOT_SAVED;
} else {
gtk_entry_set_text (entry, priv->trusted_cert);
+ gtk_toggle_button_set_active (use_otp,
+ priv->otp_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED);
}
gtk_widget_hide (dialog);
@@ -252,6 +261,17 @@ init_editor_plugin (FortisslvpnEditor *self, NMConnection *connection, GError **
gtk_entry_set_text (GTK_ENTRY (widget), priv->trusted_cert);
}
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "use_otp"));
+ if (!widget)
+ return FALSE;
+ if (s_vpn) {
+ nm_setting_get_secret_flags (NM_SETTING (s_vpn),
+ NM_FORTISSLVPN_KEY_OTP, &priv->otp_flags,
+ NULL);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
+ priv->otp_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED);
+ }
+
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "show_passwords_checkbutton"));
g_return_val_if_fail (widget != NULL, FALSE);
g_signal_connect (G_OBJECT (widget), "toggled",
@@ -418,6 +438,9 @@ update_connection (NMVpnEditor *iface,
NM_FORTISSLVPN_KEY_TRUSTED_CERT,
priv->trusted_cert);
+ /* Use OTP */
+ nm_setting_set_secret_flags (NM_SETTING (s_vpn), NM_FORTISSLVPN_KEY_OTP, priv->otp_flags, NULL);
+
nm_connection_add_setting (connection, NM_SETTING (s_vpn));
valid = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]