From 6388cc88b4a6cd803a5d2c3076a5d7d95a40ba0f Mon Sep 17 00:00:00 2001 From: mary-dcouto Date: Mon, 30 Aug 2021 21:43:23 +0530 Subject: [PATCH 1/3] notification after mfa --- service/ziti-tunnel/dto/dtos.go | 1 + service/ziti-tunnel/service/ipc.go | 26 +++++++++++++++++++++++--- service/ziti-tunnel/service/state.go | 8 ++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/service/ziti-tunnel/dto/dtos.go b/service/ziti-tunnel/dto/dtos.go index f67eb66c..eb3707b8 100644 --- a/service/ziti-tunnel/dto/dtos.go +++ b/service/ziti-tunnel/dto/dtos.go @@ -90,6 +90,7 @@ type Identity struct { MfaMaxTimeoutRem int32 MfaLastUpdatedTime time.Time ServiceUpdatedTime time.Time + Notified bool } type Metrics struct { diff --git a/service/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go index 9069b196..e21061ee 100644 --- a/service/ziti-tunnel/service/ipc.go +++ b/service/ziti-tunnel/service/ipc.go @@ -127,6 +127,7 @@ func SubMain(ops chan string, changes chan<- svc.Status, winEvents <-chan Window } } } + broadcastNotification(true) case <-shutdownDelay: log.Tracef("Exiting windows power events loop") return @@ -1140,6 +1141,12 @@ func handleBulkServiceChange(sc cziti.BulkServiceChange) { } rts.BroadcastEvent(m) + id := rts.Find(sc.Fingerprint) + if id != nil && !id.Notified { + broadcastNotification(true) + rts.SetNotified(id.FingerPrint, true) + } + } func addUnit(count int, unit string) (result string) { @@ -1193,17 +1200,26 @@ func handleEvents(isInitialized chan struct{}) { // notification message case <-notificationFrequency.C: - broadcastNotification() + broadcastNotification(false) } } } -func broadcastNotification() { +func broadcastNotification(adhoc bool) { + changedNotifiedStatus := false cleanNotifications := make([]cziti.NotificationMessage, 0) for _, id := range rts.ids { + if !id.Notified { + rts.SetNotified(id.FingerPrint, true) + changedNotifiedStatus = true + } else if id.Notified && adhoc { + continue + } + if id.CId == nil || !id.CId.MfaRefreshNeeded() { continue } + notificationMessage := "" var notificationMinTimeout int32 = 0 @@ -1238,6 +1254,10 @@ func broadcastNotification() { } } + if changedNotifiedStatus && adhoc { + ResetFrequency(rts.state.NotificationFrequency) + } + if len(cleanNotifications) > 0 { if rts.state.SnoozeNotification { log.Debugf("Notification Snoozed. Notification message: %v", cleanNotifications) @@ -1356,7 +1376,7 @@ func authMfa(out *json.Encoder, fingerprint string, code string) { if result == nil { // respond with auth success message immediately respond(out, dto.Response{Message: "AuthMFA complete", Code: SUCCESS, Error: "", Payload: fingerprint}) - + rts.SetNotified(fingerprint, false) id.CId.UpdateMFATime() } else { respondWithError(out, fmt.Sprintf("AuthMFA failed. the supplied code [%s] was not valid: %s", code, result), 1, result) diff --git a/service/ziti-tunnel/service/state.go b/service/ziti-tunnel/service/state.go index d6410f4e..cc6bc98b 100644 --- a/service/ziti-tunnel/service/state.go +++ b/service/ziti-tunnel/service/state.go @@ -556,6 +556,14 @@ func (t *RuntimeState) UpdateMfa(fingerprint string, mfaEnabled bool, mfaNeeded } } +func (t *RuntimeState) SetNotified(fingerprint string, notified bool) { + id := t.Find(fingerprint) + + if id != nil { + id.Notified = notified + } +} + func (t *RuntimeState) UpdateNotificationFrequency(notificationFreq int) error { log.Infof("setting notification frequency : %d", notificationFreq) From 96d3786a8800638089092fb035551340eaddb3ae Mon Sep 17 00:00:00 2001 From: mary-dcouto Date: Mon, 30 Aug 2021 22:27:19 +0530 Subject: [PATCH 2/3] broadcast message after mfa re-login --- service/ziti-tunnel/service/ipc.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/service/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go index e21061ee..1a9e77fc 100644 --- a/service/ziti-tunnel/service/ipc.go +++ b/service/ziti-tunnel/service/ipc.go @@ -1144,7 +1144,6 @@ func handleBulkServiceChange(sc cziti.BulkServiceChange) { id := rts.Find(sc.Fingerprint) if id != nil && !id.Notified { broadcastNotification(true) - rts.SetNotified(id.FingerPrint, true) } } @@ -1209,6 +1208,11 @@ func broadcastNotification(adhoc bool) { changedNotifiedStatus := false cleanNotifications := make([]cziti.NotificationMessage, 0) for _, id := range rts.ids { + + if id.CId == nil || !id.CId.MfaRefreshNeeded() { + continue + } + if !id.Notified { rts.SetNotified(id.FingerPrint, true) changedNotifiedStatus = true @@ -1216,10 +1220,6 @@ func broadcastNotification(adhoc bool) { continue } - if id.CId == nil || !id.CId.MfaRefreshNeeded() { - continue - } - notificationMessage := "" var notificationMinTimeout int32 = 0 @@ -1378,6 +1378,7 @@ func authMfa(out *json.Encoder, fingerprint string, code string) { respond(out, dto.Response{Message: "AuthMFA complete", Code: SUCCESS, Error: "", Payload: fingerprint}) rts.SetNotified(fingerprint, false) id.CId.UpdateMFATime() + broadcastNotification(true) } else { respondWithError(out, fmt.Sprintf("AuthMFA failed. the supplied code [%s] was not valid: %s", code, result), 1, result) } From 3b01f99fbd59b3f4e8162094a12b53aed879fa27 Mon Sep 17 00:00:00 2001 From: mary-dcouto Date: Tue, 31 Aug 2021 11:03:26 +0530 Subject: [PATCH 3/3] update release notes --- release-notes.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/release-notes.md b/release-notes.md index ebbc2544..6dc848b9 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,3 +1,18 @@ +# Release 1.10.2 + +## What's New +* none + +## Other changes: +* [#430](https://github.com/openziti/desktop-edge-win/issues/430) Snooze service timeout Notification. + - Send notification if WDE receives the service updates with timeout that is less than 5 minutes + +## Bugs fixed: +* none + +## Dependency Updates +* none + # Release 1.10.1 ## What's New