Merge branch 'release-next' into mfa-timeout-ui

This commit is contained in:
Jeremy Tellier - ROG
2021-08-06 17:15:09 +01:00
16 changed files with 183 additions and 101 deletions
+3 -3
View File
@@ -50,6 +50,6 @@ using System.Windows;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.10.0.0")]
[assembly: AssemblyVersion("1.10.0.0")]
[assembly: AssemblyFileVersion("1.10.0.0")]
// [assembly: AssemblyVersion("1.10.1.0")]
[assembly: AssemblyVersion("1.10.1.0")]
[assembly: AssemblyFileVersion("1.10.1.0")]
+3 -3
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DOCUMENT Type="Advanced Installer" CreateVersion="17.4.1" version="18.4" Modules="professional" RootPath="." Language="en" Id="{7315FE7B-0418-4F38-8B12-6C0594276D30}">
<DOCUMENT Type="Advanced Installer" CreateVersion="17.4.1" version="18.5" Modules="professional" RootPath="." Language="en" Id="{7315FE7B-0418-4F38-8B12-6C0594276D30}">
<COMPONENT cid="caphyon.advinst.msicomp.MsiPropsComponent">
<ROW Property="AI_BITMAP_DISPLAY_MODE" Value="0"/>
<ROW Property="AI_BackgroundColor" Value="lightblue" MsiKey="AI_BackgroundColor"/>
@@ -23,10 +23,10 @@
<ROW Property="CTRLS" Value="2"/>
<ROW Property="Manufacturer" Value="NetFoundry, Inc."/>
<ROW Property="MsiLogging" MultiBuildValue="AnyCPU_Release:vp"/>
<ROW Property="ProductCode" Value="1033:{3530A7C6-F816-430B-A8CC-3F98EBD35A07} " Type="16"/>
<ROW Property="ProductCode" Value="1033:{5097B3D5-F18B-4A4D-A771-29B412DF2424} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="Ziti Desktop Edge"/>
<ROW Property="ProductVersion" Value="1.10.0" Type="32"/>
<ROW Property="ProductVersion" Value="1.10.1" Type="32"/>
<ROW Property="REBOOT" MultiBuildValue="AnyCPU_Release:Suppress"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
<ROW Property="UpgradeCode" Value="{CB7E173A-663D-4A23-BB22-D1E8D885C2F3}"/>
+1 -1
View File
@@ -24,7 +24,7 @@ msbuild ZitiDesktopEdge.sln /property:Configuration=Release
Pop-Location
$ADV_INST_HOME = "C:\Program Files (x86)\Caphyon\Advanced Installer 18.4"
$ADV_INST_HOME = "C:\Program Files (x86)\Caphyon\Advanced Installer 18.5"
$ADVINST = "${ADV_INST_HOME}\bin\x86\AdvancedInstaller.com"
$ADVPROJECT = "${scriptPath}\ZitiDesktopEdge.aip"
$installerVersion=(Get-Content -Path ${scriptPath}\..\version)
+1 -1
View File
@@ -1 +1 @@
"C:\Program Files (x86)\Caphyon\Advanced Installer 18.4\bin\x86\AdvancedInstaller.com" /register %1
"C:\Program Files (x86)\Caphyon\Advanced Installer 18.5\bin\x86\AdvancedInstaller.com" /register %1
+3 -3
View File
@@ -30,6 +30,6 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.10.0.0")]
[assembly: AssemblyVersion("1.10.0.0")]
[assembly: AssemblyFileVersion("1.10.0.0")]
// [assembly: AssemblyVersion("1.10.1.0")]
[assembly: AssemblyVersion("1.10.1.0")]
[assembly: AssemblyFileVersion("1.10.1.0")]
+22 -9
View File
@@ -85,6 +85,7 @@ namespace ZitiUpdateService {
private SvcResponse TriggerUpdate() {
SvcResponse r = new SvcResponse();
r.Message = "Initiating Update Check";
checkUpdateImmediately();
return r;
}
@@ -493,6 +494,12 @@ namespace ZitiUpdateService {
};
await writer.WriteLineAsync(JsonConvert.SerializeObject(status));
await writer.FlushAsync();
if (_installationReminder != null) {
TimerState state = _installationReminder.State;
InstallationNotificationEvent notificationMsg = logAndNotifyInstallationUpdates(state.zdeInstallerInfo, true);
await writer.WriteLineAsync(JsonConvert.SerializeObject(notificationMsg));
await writer.FlushAsync();
}
}
#pragma warning disable 1998 //This async method lacks 'await'
@@ -674,6 +681,7 @@ namespace ZitiUpdateService {
if (info.IsCritical) {
info.TimeRemaining = 0;
info.InstallTime = DateTime.Now;
NotifyInstallationUpdates(info, 0, "");
installZDE(fileDestination, filename);
} else if (!info.IsCritical && _installationReminder == null) {
@@ -699,12 +707,7 @@ namespace ZitiUpdateService {
}
if (_installationReminder != null) {
info.TimeRemaining = _installationReminder.DueTime.TotalMilliseconds / 1000; // converting to seconds
info.InstallTime = DateTime.Now.AddMilliseconds(_installationReminder.DueTime.TotalMilliseconds);
Logger.Info("Installation of ZDE version {0} will be initiated in {1} seconds, approximately at {2}", info.Version, info.TimeRemaining, info.InstallTime);
if (info.TimeRemaining > 0 && (info.TimeRemaining / 1000) < 1 ) {
NotifyInstallationUpdates(info, 0, "");
}
logAndNotifyInstallationUpdates(info, false);
}
}
} catch (Exception ex) {
@@ -722,13 +725,22 @@ namespace ZitiUpdateService {
semaphore.Release();
}
private InstallationNotificationEvent logAndNotifyInstallationUpdates(Checkers.ZDEInstallerInfo info, bool newClient) {
info.TimeRemaining = _installationReminder.DueTime.TotalMilliseconds / 1000; // converting to seconds
info.InstallTime = DateTime.Now.AddMilliseconds(_installationReminder.DueTime.TotalMilliseconds);
Logger.Info("Installation of ZDE version {0} will be initiated in {1} seconds, approximately at {2}", info.Version, info.TimeRemaining, info.InstallTime);
if (newClient || (info.TimeRemaining > 0 && (info.TimeRemaining / 1000) < 1)) {
return NotifyInstallationUpdates(info, 0, "");
}
return null;
}
private void installZDE(string fileDestination, string filename) {
Logger.Info("package is in {0} - moving to install phase", fileDestination);
if (!check.HashIsValid(updateFolder, filename)) {
Logger.Warn("The file was downloaded but the hash is not valid. The file will be removed: {0}", fileDestination);
File.Delete(fileDestination);
semaphore.Release();
return;
}
Logger.Debug("downloaded file hash was correct. update can continue.");
@@ -932,7 +944,7 @@ namespace ZitiUpdateService {
}
}
private void NotifyInstallationUpdates(Checkers.ZDEInstallerInfo info, int code, string error) {
private InstallationNotificationEvent NotifyInstallationUpdates(Checkers.ZDEInstallerInfo info, int code, string error) {
try {
InstallationNotificationEvent installationNotificationEvent = new InstallationNotificationEvent() {
Code = code,
@@ -947,10 +959,11 @@ namespace ZitiUpdateService {
};
EventRegistry.SendEventToConsumers(installationNotificationEvent);
Logger.Debug("The installation updates for version {0} is sent to the events pipe...", info.Version);
return installationNotificationEvent;
} catch (Exception e) {
Logger.Error("The notification for the installation updates for version {0} has failed", info.Version);
}
return null;
}
}
+3
View File
@@ -15,6 +15,7 @@ namespace ZitiUpdateService.Utils {
private DateTime _next;
private DateTime _lastTickTime;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private TimerState _state;
public CustomTimer(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period) {
_timer = new Timer(Callback, state, dueTime, period);
@@ -22,6 +23,7 @@ namespace ZitiUpdateService.Utils {
_period = period;
_next = DateTime.Now.Add(dueTime);
_lastTickTime = DateTime.Now;
_state = (TimerState)state;
}
private void Callback(object state) {
@@ -32,6 +34,7 @@ namespace ZitiUpdateService.Utils {
public TimeSpan Period => _period;
public DateTime Next => _next;
public TimeSpan DueTime => _next - DateTime.Now;
public TimerState State => _state;
public bool Change(TimeSpan dueTime, TimeSpan period) {
_period = period;
_next = DateTime.Now.Add(dueTime);
+15 -2
View File
@@ -1,14 +1,27 @@
# Release 1.10.0
# Release 1.10.1
## What's New
* none
## Other changes:
* [#421](https://github.com/openziti/desktop-edge-win/issues/421) Calculate timeoutRemaining based on the service updates time or mfa auth time
## Bugs fixed:
* none
## Dependency Updates
* updated c-sdk to v0.25.6, updated t-sdk to v0.15.12
# Release 1.10.0
## What's New
* mfa timeout process. ZDE will prompt the user to enter MFA token, when the timeout set for the services is about to expire. Sends notification periodically until MFA token is entered
* [#418](https://github.com/openziti/desktop-edge-win/issues/418) notification has to be sent based on timeout remaining field. When User enters auth Mfa, the timer will reset to original timeout field. timeout remaining field will also be reset to the value in timeout field
* [#278](https://github.com/openziti/desktop-edge-win/issues/278) inform the user an update is available before automatically updating. So user can manually install the latest version anytime within 2 hours after the release is published. If a major/minor version has changed, then the auto installation will start immediately. If the user does not initiate manual installation within the given time, a warning will be displayed and after 2 hours the ZDE will auto update.
* mfa timeout process
## Other changes:
* [#381](https://github.com/openziti/desktop-edge-win/issues/381) Open Ziti UI on startup.
* [#415](https://github.com/openziti/desktop-edge-win/issues/415) The notification frequency should be between 5 and 20 minutes. ZDE accepts the requests to modify it (UI is not ready yet). 20 minutes before the timeout, it should start sending the notification to UI
## Bugs fixed:
* none
+1 -1
View File
@@ -14,7 +14,7 @@ REM See the License for the specific language governing permissions and
REM limitations under the License.
REM
SET REPO_URL=https://github.com/openziti/ziti-tunnel-sdk-c.git
SET ZITI_TUNNEL_REPO_BRANCH=v0.15.10
SET ZITI_TUNNEL_REPO_BRANCH=v0.15.12
REM override the c sdk used in the build - leave blank for the same as specified in the tunneler sdk
SET ZITI_SDK_C_BRANCH=
REM the number of TCP connections the tunneler sdk can have at any one time
+1 -1
View File
@@ -303,5 +303,5 @@ func ziti_mfa_cb_remove_go(_ C.ziti_context, status C.int, cFingerprint *C.char)
func EndpointStateChanged(id *ZIdentity, woken bool, unlocked bool) {
C.ziti_endpoint_state_change(id.czctx, C.bool(woken), C.bool(unlocked))
log.Debugf("Endpoint status changed for id %s - woken %t, unlocked %t", id.Fingerprint, woken, unlocked)
log.Debugf("Endpoint status changed for id %s:%s - woken %t, unlocked %t", id.Name, id.Fingerprint, woken, unlocked)
}
+40 -12
View File
@@ -86,6 +86,7 @@ type BulkServiceChange struct {
MfaMinTimeoutRem int32
MfaMaxTimeoutRem int32
MfaLastUpdatedTime time.Time
ServiceUpdatedTime time.Time
}
type NotificationMessage struct {
@@ -162,6 +163,7 @@ type ZIdentity struct {
MfaMinTimeoutRem int32
MfaMaxTimeoutRem int32
MfaLastUpdatedTime time.Time
ServiceUpdatedTime time.Time
}
func NewZid(statusChange func(int)) *ZIdentity {
@@ -174,6 +176,7 @@ func NewZid(statusChange func(int)) *ZIdentity {
zid.MfaMaxTimeout = -1
zid.MfaMinTimeout = -1
zid.MfaLastUpdatedTime = time.Now()
zid.ServiceUpdatedTime = time.Now()
return zid
}
@@ -257,14 +260,27 @@ func (zid *ZIdentity) MfaRefreshNeeded() bool {
return !(zid.MfaMinTimeoutRem == -1 && zid.MfaMaxTimeoutRem == -1)
}
func (zid *ZIdentity) GetRemainingTime(timeout int32) int32 {
func (zid *ZIdentity) GetRemainingTime(timeout int32, timeoutRemaining int32) int32 {
var remainingTimeout int32
if (timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds())) <= 0 {
remainingTimeout = 0
// calculate effective timeout remaining from last mfa or service update time
if zid.MfaLastUpdatedTime.After(zid.ServiceUpdatedTime) {
//calculate svc remaining timeout
if (timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds())) < 0 {
remainingTimeout = 0
} else {
remainingTimeout = timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds())
}
} else {
remainingTimeout = timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds())
//calculate svc remaining timeout
if (timeoutRemaining - int32(time.Since(zid.ServiceUpdatedTime).Seconds())) < 0 {
remainingTimeout = 0
} else {
remainingTimeout = timeoutRemaining - int32(time.Since(zid.ServiceUpdatedTime).Seconds())
}
}
return remainingTimeout
}
func (zid *ZIdentity) GetMFAState(interval int32) int {
@@ -428,18 +444,26 @@ func serviceCB(ziti_ctx C.ziti_context, service *C.ziti_service, status C.int, z
var pcId string
pcId = C.GoString(pq.id)
log.Infof("Posture query %s, timeout %d, timeoutRemaining %d", C.GoString(pq.id), int(pq.timeout), int(pq.timeoutRemaining))
var pcTimeoutRemaining int
if unsafe.Pointer(pq.timeoutRemaining) != C.NULL {
pcTimeoutRemaining = int(*(*C.int)(pq.timeoutRemaining))
} else {
pcTimeoutRemaining = -1
}
log.Infof("Posture query %s, timeout %d, timeoutRemaining %d", pcId, int(pq.timeout), pcTimeoutRemaining)
_, found := pcIds[pcId]
if found {
log.Tracef("posture check with id %s already in failing posture check map", pcId)
for _, pc := range postureChecks {
if pc.Id == C.GoString(pq.id) {
if pc.Id == pcId {
if timeout == -1 || timeout > int(pq.timeout) {
timeout = int(pq.timeout)
}
if timeoutRemaining == -1 || timeoutRemaining > int(pq.timeoutRemaining) {
timeoutRemaining = int(pq.timeoutRemaining)
if timeoutRemaining == -1 || timeoutRemaining > pcTimeoutRemaining {
timeoutRemaining = pcTimeoutRemaining
}
break
}
@@ -451,7 +475,7 @@ func serviceCB(ziti_ctx C.ziti_context, service *C.ziti_service, status C.int, z
QueryType: C.GoString(pq.query_type),
Id: pcId,
Timeout: int(pq.timeout),
TimeoutRemaining: int(pq.timeoutRemaining),
TimeoutRemaining: pcTimeoutRemaining,
}
timeout = pc.Timeout
timeoutRemaining = pc.TimeoutRemaining
@@ -626,6 +650,7 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) {
var minimumTimeoutRem int32 = -1
var maximumTimeoutRem int32 = -1
noTimeoutSvc := false
noTimeoutRemSvc := false
if len(servicesToAdd) > 0 {
zid.Services.Range(func(key interface{}, value interface{}) bool {
//string, ZService
@@ -649,7 +674,7 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) {
maximumTimeoutRem = val.Service.TimeoutRemaining
}
} else {
noTimeoutSvc = true
noTimeoutRemSvc = true
}
return true
@@ -657,6 +682,8 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) {
})
if noTimeoutSvc {
maximumTimeout = -1
}
if noTimeoutRemSvc {
maximumTimeoutRem = -1
}
}
@@ -666,7 +693,7 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) {
zid.MfaMaxTimeout = maximumTimeout
zid.MfaMinTimeoutRem = minimumTimeoutRem
zid.MfaMaxTimeoutRem = maximumTimeoutRem
zid.MfaLastUpdatedTime = now
zid.ServiceUpdatedTime = now
svcChange := BulkServiceChange{
Fingerprint: zid.Fingerprint,
@@ -678,7 +705,8 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) {
MfaMaxTimeout: maximumTimeout,
MfaMinTimeoutRem: minimumTimeoutRem,
MfaMaxTimeoutRem: maximumTimeoutRem,
MfaLastUpdatedTime: now,
MfaLastUpdatedTime: zid.MfaLastUpdatedTime,
ServiceUpdatedTime: now,
}
if len(BulkServiceChanges) == cap(BulkServiceChanges) {
+1
View File
@@ -278,6 +278,7 @@ github.com/openziti/foundation v0.15.44/go.mod h1:kYCUttsGO/GjoD7BSNhVOeyYDXHYMA
github.com/openziti/sdk-golang v0.15.35 h1:SAHJk1y0SDlXnMXDoLGSaHrrTs511sWVDPBePyLk6r0=
github.com/openziti/sdk-golang v0.15.35/go.mod h1:jrvkpxP7U1ejSKEj4J9/UTNWlt6nJaofUGKkTx7afvM=
github.com/openziti/sdk-golang v0.15.43 h1:Lz65VocDRtdt0aR0JmK767UkRvtEz4Wm4PG4/bvJuDM=
github.com/openziti/sdk-golang v0.15.68 h1:KsHBbybpTfcQFSGFOQyO/C2x9HVBwT2BHdJJHaQckiI=
github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU=
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
+2
View File
@@ -89,6 +89,8 @@ type Identity struct {
MfaMinTimeoutRem int32
MfaMaxTimeoutRem int32
MfaLastUpdatedTime time.Time
ServiceUpdatedTime time.Time
}
type Metrics struct {
Up int64
+83 -61
View File
@@ -1136,6 +1136,7 @@ func handleBulkServiceChange(sc cziti.BulkServiceChange) {
},
}
rts.BroadcastEvent(m)
}
func addUnit(count int, unit string) (result string) {
@@ -1189,56 +1190,60 @@ func handleEvents(isInitialized chan struct{}) {
// notification message
case <-notificationFrequency.C:
cleanNotifications := make([]cziti.NotificationMessage, 0)
for _, id := range rts.ids {
if id.CId == nil || !id.CId.MfaRefreshNeeded() {
continue
}
notificationMessage := ""
var notificationMinTimeout int32 = 0
var notificationMaxTimeout int32 = -1
switch mfaState := id.CId.GetMFAState(int32((constants.MaximumFrequency + rts.state.NotificationFrequency) * 60)); mfaState {
case constants.MfaAllSvcTimeout:
notificationMessage = fmt.Sprintf("All of the services of identity %s are timed out", id.Name)
case constants.MfaFewSvcTimeout:
notificationMessage = fmt.Sprintf("Some of the services of identity %s are timed out", id.Name)
case constants.MfaNearingTimeout:
notificationMinTimeout = id.CId.GetRemainingTime(id.CId.MfaMinTimeoutRem)
notificationMessage = fmt.Sprintf("Some of the services of identity %s are timing out in %s", id.Name, secondsToReadableFmt(notificationMinTimeout))
default:
// do nothing
}
if len(notificationMessage) > 0 {
if id.CId.MfaMaxTimeoutRem > -1 {
notificationMaxTimeout = id.CId.GetRemainingTime(id.CId.MfaMaxTimeoutRem)
}
notificationMinTimeout = id.CId.GetRemainingTime(id.CId.MfaMinTimeoutRem)
cleanNotifications = append(cleanNotifications, cziti.NotificationMessage{
Fingerprint: id.FingerPrint,
IdentityName: id.Name,
Severity: "major",
MfaMinimumTimeout: notificationMinTimeout,
MfaMaximumTimeout: notificationMaxTimeout,
Message: notificationMessage,
MfaTimeDuration: int(time.Since(id.CId.MfaLastUpdatedTime).Seconds()),
})
}
}
if len(cleanNotifications) > 0 {
log.Debugf("Sending notification message to UI %v", cleanNotifications)
rts.BroadcastEvent(cziti.TunnelNotificationEvent{
Op: "notification",
Notification: cleanNotifications,
})
}
broadcastNotification()
}
}
}
func broadcastNotification() {
cleanNotifications := make([]cziti.NotificationMessage, 0)
for _, id := range rts.ids {
if id.CId == nil || !id.CId.MfaRefreshNeeded() {
continue
}
notificationMessage := ""
var notificationMinTimeout int32 = 0
var notificationMaxTimeout int32 = -1
switch mfaState := id.CId.GetMFAState(int32((constants.MaximumFrequency + rts.state.NotificationFrequency) * 60)); mfaState {
case constants.MfaAllSvcTimeout:
notificationMessage = fmt.Sprintf("All of the services of identity %s are timed out", id.Name)
case constants.MfaFewSvcTimeout:
notificationMessage = fmt.Sprintf("Some of the services of identity %s are timed out", id.Name)
case constants.MfaNearingTimeout:
notificationMinTimeout = id.CId.GetRemainingTime(id.CId.MfaMinTimeout, id.CId.MfaMinTimeoutRem)
notificationMessage = fmt.Sprintf("Some of the services of identity %s are timing out in %s", id.Name, secondsToReadableFmt(notificationMinTimeout))
default:
// do nothing
}
if len(notificationMessage) > 0 {
if id.CId.MfaMaxTimeoutRem > -1 {
notificationMaxTimeout = id.CId.GetRemainingTime(id.CId.MfaMaxTimeout, id.CId.MfaMaxTimeoutRem)
}
notificationMinTimeout = id.CId.GetRemainingTime(id.CId.MfaMinTimeout, id.CId.MfaMinTimeoutRem)
cleanNotifications = append(cleanNotifications, cziti.NotificationMessage{
Fingerprint: id.FingerPrint,
IdentityName: id.Name,
Severity: "major",
MfaMinimumTimeout: notificationMinTimeout,
MfaMaximumTimeout: notificationMaxTimeout,
Message: notificationMessage,
MfaTimeDuration: int(time.Since(id.CId.MfaLastUpdatedTime).Seconds()),
})
}
}
if len(cleanNotifications) > 0 {
log.Debugf("Sending notification message to UI %v", cleanNotifications)
rts.BroadcastEvent(cziti.TunnelNotificationEvent{
Op: "notification",
Notification: cleanNotifications,
})
}
}
func ResetFrequency(newFrequency int) {
notificationFrequency.Reset(time.Duration(newFrequency) * time.Minute)
}
@@ -1270,23 +1275,39 @@ func Clean(src *Id) dto.Identity {
}
if src.CId != nil {
var mfaMinTimeoutRemaining int32 = -1
var mfaMaxTimeoutRemaining int32 = -1
src.CId.Services.Range(func(key interface{}, value interface{}) bool {
//string, ZService
val := value.(*cziti.ZService)
var svcMinTimeoutRemaining int32 = -1
if src.CId.MfaRefreshNeeded() && val.Service.TimeoutRemaining > 0 {
var svcTimeout int32 = -1
var svcTimeoutRemaining int32 = -1
// fetch svc timeout and timeout remaining from pc
for _, pc := range val.Service.PostureChecks {
if svcTimeout == -1 || svcTimeout > int32(pc.TimeoutRemaining) {
svcTimeout = int32(pc.TimeoutRemaining)
if svcTimeout == -1 || svcTimeout > int32(pc.Timeout) {
svcTimeout = int32(pc.Timeout)
}
if svcTimeoutRemaining == -1 || svcTimeoutRemaining > int32(pc.TimeoutRemaining) {
svcTimeoutRemaining = int32(pc.TimeoutRemaining)
}
break
}
if (svcTimeout - int32(time.Since(src.CId.MfaLastUpdatedTime).Seconds())) < 0 {
atomic.StoreInt32(&val.Service.TimeoutRemaining, 0)
} else {
atomic.StoreInt32(&val.Service.TimeoutRemaining, svcTimeout-int32(time.Since(src.CId.MfaLastUpdatedTime).Seconds()))
// calculate effective timeout remaining from last mfa or service update time
svcMinTimeoutRemaining = src.CId.GetRemainingTime(svcTimeout, svcTimeoutRemaining)
//calculate mfa min remaining timeout
if mfaMinTimeoutRemaining == -1 && src.CId.MfaMinTimeoutRem != -1 {
mfaMinTimeoutRemaining = src.CId.GetRemainingTime(src.CId.MfaMinTimeout, src.CId.MfaMinTimeoutRem)
}
//calculate mfa max remaining timeout
if mfaMaxTimeoutRemaining == -1 && src.CId.MfaMaxTimeoutRem != -1 {
mfaMaxTimeoutRemaining = src.CId.GetRemainingTime(src.CId.MfaMaxTimeout, src.CId.MfaMaxTimeoutRem)
}
atomic.StoreInt32(&val.Service.TimeoutRemaining, svcMinTimeoutRemaining)
}
nid.Services = append(nid.Services /*svcToDto(val)*/, val.Service)
@@ -1294,13 +1315,12 @@ func Clean(src *Id) dto.Identity {
})
nid.MfaMinTimeout = src.CId.MfaMinTimeout
nid.MfaMaxTimeout = src.CId.MfaMaxTimeout
nid.MfaMinTimeoutRem = src.CId.MfaMinTimeoutRem
nid.MfaMaxTimeoutRem = src.CId.MfaMaxTimeoutRem
if !src.CId.MfaRefreshNeeded() {
nid.MfaLastUpdatedTime = time.Now()
} else {
nid.MfaLastUpdatedTime = src.CId.MfaLastUpdatedTime
if (nid.MfaMaxTimeoutRem-int32(time.Since(nid.MfaLastUpdatedTime).Seconds())) < 0 && nid.MfaEnabled {
nid.MfaMinTimeoutRem = mfaMinTimeoutRemaining
nid.MfaMaxTimeoutRem = mfaMaxTimeoutRemaining
nid.ServiceUpdatedTime = src.CId.ServiceUpdatedTime
nid.MfaLastUpdatedTime = src.CId.MfaLastUpdatedTime
if src.CId.MfaRefreshNeeded() {
if (nid.MfaMaxTimeoutRem > -1 && (nid.MfaMaxTimeoutRem-int32(time.Since(nid.MfaLastUpdatedTime).Seconds())) < 0) && nid.MfaEnabled {
nid.MfaNeeded = true
}
}
@@ -1326,8 +1346,10 @@ func authMfa(out *json.Encoder, fingerprint string, code string) {
id := rts.Find(fingerprint)
result := cziti.AuthMFA(id.CId, code)
if result == nil {
id.CId.UpdateMFATime()
// respond with auth success message immediately
respond(out, dto.Response{Message: "AuthMFA complete", Code: SUCCESS, Error: "", Payload: fingerprint})
id.CId.UpdateMFATime()
} else {
respondWithError(out, fmt.Sprintf("AuthMFA failed. the supplied code [%s] was not valid: %s", code, result), 1, result)
}
+3 -3
View File
@@ -20,9 +20,9 @@
package main
const (
Version = "1.10.0"
Revision = "75ba67f8120d"
Version = "1.10.1"
Revision = "4ac4dd9c46dc"
Branch = "release-next"
BuildUser = ""
BuildDate = "2021-07-28 05:58:20"
BuildDate = "2021-08-06 15:28:13"
)
+1 -1
View File
@@ -1 +1 @@
1.10.0
1.10.1