Merge pull request #770 from openziti/fix-mfa-panic

Fix panic if posture data mfa is nil
This commit is contained in:
Paul Lorenz
2021-09-09 11:24:42 -04:00
committed by GitHub
2 changed files with 10 additions and 2 deletions
@@ -91,9 +91,10 @@ func (r *PostureResponseRouter) CreateBulk(ae *env.AppEnv, rc *response.RequestC
postureData := ae.Handlers.PostureResponse.PostureData(rc.Identity.Id)
if postureData != nil && postureData.ApiSessions != nil {
if apiPostureData, ok := postureData.ApiSessions[rc.ApiSession.Id]; ok && apiPostureData.Mfa.PassedMfaAt != nil {
apiPostureData := postureData.ApiSessions[rc.ApiSession.Id]
if passedMfaAt := apiPostureData.GetPassedMfaAt(); passedMfaAt != nil {
//if the last time Mfa was passed at is outside of the grace period, send timeout update
durationSinceLastMfa := time.Now().Sub(*apiPostureData.Mfa.PassedMfaAt)
durationSinceLastMfa := time.Now().Sub(*passedMfaAt)
modelServicesWithTimeouts := ae.Handlers.PostureResponse.GetEndpointStateChangeAffectedServices(durationSinceLastMfa, gracePeriod, onWake, onUnlock)
@@ -388,6 +388,13 @@ type ApiSessionPostureData struct {
SdkInfo *SdkInfo
}
func (self *ApiSessionPostureData) GetPassedMfaAt() *time.Time {
if self == nil || self.Mfa == nil {
return nil
}
return self.Mfa.PassedMfaAt
}
type PostureCheckFailureSubType interface {
Value() interface{}
Expected() interface{}