mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-14 08:39:55 +00:00
Merge pull request #433 from openziti/notification-after-mfa
Notification after mfa
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -90,6 +90,7 @@ type Identity struct {
|
||||
MfaMaxTimeoutRem int32
|
||||
MfaLastUpdatedTime time.Time
|
||||
ServiceUpdatedTime time.Time
|
||||
Notified bool
|
||||
|
||||
}
|
||||
type Metrics struct {
|
||||
|
||||
@@ -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
|
||||
@@ -1137,6 +1138,11 @@ func handleBulkServiceChange(sc cziti.BulkServiceChange) {
|
||||
}
|
||||
rts.BroadcastEvent(m)
|
||||
|
||||
id := rts.Find(sc.Fingerprint)
|
||||
if id != nil && !id.Notified {
|
||||
broadcastNotification(true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func addUnit(count int, unit string) (result string) {
|
||||
@@ -1190,17 +1196,27 @@ 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.CId == nil || !id.CId.MfaRefreshNeeded() {
|
||||
continue
|
||||
}
|
||||
|
||||
if !id.Notified {
|
||||
rts.SetNotified(id.FingerPrint, true)
|
||||
changedNotifiedStatus = true
|
||||
} else if id.Notified && adhoc {
|
||||
continue
|
||||
}
|
||||
|
||||
notificationMessage := ""
|
||||
|
||||
var notificationMinTimeout int32 = 0
|
||||
@@ -1235,6 +1251,10 @@ func broadcastNotification() {
|
||||
}
|
||||
}
|
||||
|
||||
if changedNotifiedStatus && adhoc {
|
||||
ResetFrequency(rts.state.NotificationFrequency)
|
||||
}
|
||||
|
||||
if len(cleanNotifications) > 0 {
|
||||
log.Debugf("Sending notification message to UI %v", cleanNotifications)
|
||||
|
||||
@@ -1349,8 +1369,9 @@ 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()
|
||||
broadcastNotification(true)
|
||||
} else {
|
||||
respondWithError(out, fmt.Sprintf("AuthMFA failed. the supplied code [%s] was not valid: %s", code, result), 1, result)
|
||||
}
|
||||
|
||||
@@ -555,6 +555,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)
|
||||
|
||||
Reference in New Issue
Block a user