Add 20 minute check for icon display and double validate that MFA is enabled since service could return a timeout when its not even set.

This commit is contained in:
Jeremy Tellier - ROG
2021-07-29 22:44:50 +01:00
parent 92f8d1c0db
commit e62d57e9c9
6 changed files with 32 additions and 8 deletions
+11
View File
@@ -257,6 +257,15 @@ namespace ZitiDesktopEdge {
for (int i=0; i<identities.Count; i++) {
if (identities[i].Fingerprint==MFASetup.Identity.Fingerprint) {
identities[i] = MFASetup.Identity;
// This will set the timout in the UI to not show the timing out icon but as you can see
// it is not real and won't properly update until a real timeout is sent via the service
// 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;
}
}
}
}
@@ -268,6 +277,8 @@ namespace ZitiDesktopEdge {
} else if (MFASetup.Type == 3) {
IdentityMenu.Identity.IsMFAEnabled = false;
IdentityMenu.Identity.MFAInfo.IsAuthenticated = false;
IdentityMenu.Identity.IsTimingOut = false;
await ShowBlurbAsync("MFA Disabled, Service Access Can Be Limited", "");
} else if (MFASetup.Type == 4) {
ShowRecovery(IdentityMenu.Identity);
+6
View File
@@ -75,11 +75,17 @@ namespace ZitiDesktopEdge.Models {
TimeoutMessage = ""
};
if (!zid.IsMFAEnabled) zid.IsTimingOut = false;
if (id.Services != null) {
foreach (var svc in id.Services) {
if (svc != null) {
var zsvc = new ZitiService(svc);
zid.Services.Add(zsvc);
if (zid.IsMFAEnabled) {
double timeSince = (DateTime.Now - zsvc.TimeUpdated).TotalMinutes;
if (timeSince >= (zsvc.Timeout-20)) zid.IsTimingOut = true;
}
}
}
zid.HasServiceFailingPostureCheck = zid.Services.Any(p => !p.HasFailingPostureCheck());
@@ -29,7 +29,7 @@
<Label Name="ToggleStatus" Grid.Column="0" Grid.Row="1" Margin="0,-5,0,0" Content="Enabled" Foreground="White" FontSize="11" Typography.Capitals="AllSmallCaps" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"></Label>
<Rectangle Fill="Transparent" Grid.Column="0" Grid.RowSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Cursor="Hand" MouseUp="ToggledSwitch"></Rectangle>
<Label Name="IdName" MaxWidth="230" Grid.Row="0" Grid.Column="1" VerticalAlignment="Bottom" Margin="0,6,0,0" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" FontSize="16" Foreground="White" HorizontalAlignment="Left">
<Label Name="IdName" MaxWidth="230" Grid.Row="0" Padding="0,0,26,0" Grid.Column="1" VerticalAlignment="Bottom" Margin="0,6,0,0" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" FontSize="16" Foreground="White" HorizontalAlignment="Left">
<TextBlock TextTrimming="CharacterEllipsis">Identity Name</TextBlock>
</Label>
<Image Name="TimerCountdown" Visibility="Collapsed" Grid.Row="0" Grid.Column="1" Source="/Assets/Images/timer.png" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="15" Height="16" Margin="0,0,0,6" Cursor="Hand" MouseUp="MFAAuthenticate"></Image>
@@ -65,7 +65,7 @@ namespace ZitiDesktopEdge {
ServiceCount.Content = _identity.Services.Count.ToString();
}
TimerCountdown.ToolTip = _identity.TimeoutMessage;
TimerCountdown.Visibility = (_identity.IsTimingOut) ? Visibility.Visible : Visibility.Collapsed;
TimerCountdown.Visibility = _identity.IsTimingOut ? Visibility.Visible : Visibility.Collapsed;
if (ToggleSwitch.Enabled) {
ToggleStatus.Content = "ENABLED";
} else {
@@ -73,11 +73,14 @@ namespace ZitiDesktopEdge {
TimerColumn.Width = new GridLength(0);
TimerIcon.Visibility = Visibility.Collapsed;
double timeSince = (DateTime.Now - this._info.TimeUpdated).TotalMinutes;
if (timeSince >= this._info.Timeout) {
TimerIcon.Visibility = Visibility.Visible;
TimerColumn.Width = new GridLength(30);
if (this._info.Timeout>-1) {
double timeSince = (DateTime.Now - this._info.TimeUpdated).TotalMinutes;
if (timeSince >= (this._info.Timeout - 20)) {
TimerIcon.Visibility = Visibility.Visible;
TimerColumn.Width = new GridLength(30);
}
}
WarningColumn.Width = new GridLength(0);
@@ -218,10 +218,13 @@ namespace ZitiDesktopEdge {
DetailPorts.Text = info.PortString;
DetailUrl.Text = info.ToString();
if (info.Timeout>-1) {
if (info.Timeout>-1&&_identity.IsMFAEnabled) {
double timeSince = (DateTime.Now - info.TimeUpdated).TotalMinutes;
if (timeSince>0) {
TimeoutDetails.Text = timeSince+ " minutes";
TimeSpan t = TimeSpan.FromSeconds(timeSince);
string answer = string.Format("{0:D2} days {1:D2} hours {2:D2} minutes", t.Hours, t.Minutes);
TimeoutDetails.Text = answer;
} else {
TimeoutDetails.Text = "Timed out";
}
@@ -399,6 +402,7 @@ namespace ZitiDesktopEdge {
ZitiService zitiSvc = services[i];
if (index < PerPage) {
if (zitiSvc.Name.ToLower().IndexOf(filter.ToLower()) >= 0 || zitiSvc.ToString().ToLower().IndexOf(filter.ToLower()) >= 0) {
zitiSvc.TimeUpdated = _identity.LastUpdatedTime;
ZitiServices.Add(zitiSvc);
index++;
}