The UI "handling" the MFA Timout

This commit is contained in:
Jeremy Tellier - ROG
2021-08-06 16:25:12 +01:00
parent 094f0f912b
commit 18036d973f
5 changed files with 37 additions and 15 deletions
+6 -5
View File
@@ -132,6 +132,7 @@ namespace ZitiDesktopEdge {
} else if (mfa.Action == "enrollment_remove") {
// ShowBlurb("removed mfa: " + mfa.Successful, "");
} else if (mfa.Action == "mfa_auth_status") {
// serviceClient.GetStatusAsync();
// ShowBlurb("mfa authenticated: " + mfa.Successful, "");
} else {
await ShowBlurbAsync ("Unexpected error when processing MFA", "");
@@ -263,9 +264,7 @@ namespace ZitiDesktopEdge {
// and if someone pages the service list and we have not got an update from the service
// this will also be invalid
identities[i].IsTimingOut = false;
for (int j=0; j<identities[i].Services.Count; j++) {
identities[i].Services[j].Timeout = -1;
}
identities[i].LastUpdatedTime = DateTime.Now;
}
}
}
@@ -594,14 +593,16 @@ namespace ZitiDesktopEdge {
continue;
} else {
found.TimeoutMessage = notification.Message;
found.MaxTimeout = notification.MfaMaximumTimeout;
found.MinTimeout = notification.MfaMinimumTimeout;
ShowToast(found.TimeoutMessage);
// Send Notification
if (notification.MfaTimeoutDuration == 0) {
if (notification.MfaMinimumTimeout == 0) {
found.MFAInfo.IsAuthenticated = false;
// display mfa token icon
displayMFARequired = true;
} else {
if (notification.MfaTimeoutDuration<1200) {
if (notification.MfaMinimumTimeout<1200) {
found.IsTimingOut = true;
}
}
+1 -1
View File
@@ -70,7 +70,7 @@ namespace ZitiDesktopEdge.Models {
},
MinTimeout = id.MinTimeout,
MaxTimeout = id.MaxTimeout,
LastUpdatedTime = id.LastUpdatedTime,
LastUpdatedTime = id.MfaLastUpdatedTime,
TimeoutMessage = ""
};
@@ -25,6 +25,7 @@ namespace ZitiDesktopEdge {
public event StatusChanged OnStatusChanged;
public delegate void OnAuthenticate(ZitiIdentity identity);
public event OnAuthenticate Authenticate;
private System.Windows.Forms.Timer _timer;
public ZitiIdentity _identity;
public ZitiIdentity Identity {
@@ -45,6 +46,13 @@ namespace ZitiDesktopEdge {
MfaRequired.Visibility = Visibility.Collapsed;
ServiceCountAreaLabel.Content = "services";
MainArea.Opacity = 1.0;
if (_identity.MaxTimeout>0) {
if (_timer != null) _timer.Stop();
_timer = new System.Windows.Forms.Timer();
_timer.Interval = _identity.MaxTimeout;
_timer.Tick += TimerTicked;
_timer.Start();
}
} else {
ServiceCountArea.Visibility = Visibility.Collapsed;
MfaRequired.Visibility = Visibility.Visible;
@@ -73,6 +81,12 @@ namespace ZitiDesktopEdge {
}
}
private void TimerTicked(object sender, EventArgs e) {
_identity.MFAInfo.IsAuthenticated = false;
RefreshUI();
_timer.Stop();
}
public IdentityItem() {
InitializeComponent();
ToggleSwitch.OnToggled += ToggleIdentity;
@@ -221,14 +221,22 @@ namespace ZitiDesktopEdge {
try {
if (_identity.IsMFAEnabled) {
if (info.TimeoutRemaining > 0) {
TimeSpan t = TimeSpan.FromSeconds(info.TimeoutRemaining);
// t = TimeSpan.FromSeconds(info.TimeoutRemaining);
TimeSpan t = (DateTime.Now - info.TimeUpdated);
int timeout = info.Timeout - (int)Math.Floor(t.TotalSeconds);
string answer = string.Format("{0:D2} minutes", t.Minutes);
if (t.Days>0) answer = string.Format("{0:D2} days {1:D2} hours {2:D2} minutes", t.Days, t.Hours, t.Minutes);
else {
if (t.Hours>0) answer = string.Format("{0:D2} hours {1:D2} minutes", t.Hours, t.Minutes);
if (timeout>0) {
t = TimeSpan.FromSeconds(timeout);
string answer = string.Format("{0:D2} minutes", t.Minutes);
if (t.Days > 0) answer = string.Format("{0:D2} days {1:D2} hours {2:D2} minutes", t.Days, t.Hours, t.Minutes);
else {
if (t.Hours > 0) answer = string.Format("{0:D2} hours {1:D2} minutes", t.Hours, t.Minutes);
}
TimeoutDetails.Text = answer;
} else {
TimeoutDetails.Text = "Timed Out";
}
TimeoutDetails.Text = answer;
} else {
TimeoutDetails.Text = "Timed Out";
}
@@ -246,7 +246,7 @@ namespace ZitiDesktopEdge.DataStructures {
public bool MfaNeeded { get; set; }
public int MinTimeout { get; set; }
public int MaxTimeout { get; set; }
public DateTime LastUpdatedTime { get; set; }
public DateTime MfaLastUpdatedTime { get; set; }
}
public class Service {
@@ -332,8 +332,7 @@ namespace ZitiDesktopEdge.DataStructures {
public string Message { get; set; }
public int MfaMinimumTimeout { get; set; }
public int MfaMaximumTimeout { get; set; }
public int TimeDuration { get; set; }
public int MfaTimeoutDuration { get; set; }
public int MfaTimeDuration { get; set; }
public string Severity { get; set; }
}