diff --git a/lib/web/apiserver.go b/lib/web/apiserver.go index 8fd4b129e85be..48a1d214ca3cf 100644 --- a/lib/web/apiserver.go +++ b/lib/web/apiserver.go @@ -879,33 +879,23 @@ func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprou } // get auth type & second factor type - authType := constants.Local - secondFactor := constants.SecondFactorOff - localAuth := true - cap, err := h.cfg.ProxyClient.GetAuthPreference(r.Context()) - if err != nil { + var authSettings ui.WebConfigAuthSettings + if cap, err := h.cfg.ProxyClient.GetAuthPreference(r.Context()); err != nil { h.log.WithError(err).Error("Cannot retrieve AuthPreferences.") + authSettings = ui.WebConfigAuthSettings{ + Providers: authProviders, + SecondFactor: constants.SecondFactorOff, + LocalAuthEnabled: true, + AuthType: constants.Local, + } } else { - authType = cap.GetType() - secondFactor = cap.GetSecondFactor() - localAuth = cap.GetAllowLocalAuth() - } - - // disable joining sessions if proxy session recording is enabled - canJoinSessions := true - recCfg, err := h.cfg.ProxyClient.GetSessionRecordingConfig(r.Context()) - if err != nil { - h.log.WithError(err).Error("Cannot retrieve SessionRecordingConfig.") - } else { - canJoinSessions = services.IsRecordAtProxy(recCfg.GetMode()) == false - } - - authSettings := ui.WebConfigAuthSettings{ - Providers: authProviders, - SecondFactor: secondFactor, - LocalAuthEnabled: localAuth, - AuthType: authType, - PreferredLocalMFA: cap.GetPreferredLocalMFA(), + authSettings = ui.WebConfigAuthSettings{ + Providers: authProviders, + SecondFactor: cap.GetSecondFactor(), + LocalAuthEnabled: cap.GetAllowLocalAuth(), + AuthType: cap.GetType(), + PreferredLocalMFA: cap.GetPreferredLocalMFA(), + } } // get tunnel address to display on cloud instances @@ -919,6 +909,15 @@ func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprou } } + // disable joining sessions if proxy session recording is enabled + canJoinSessions := true + recCfg, err := h.cfg.ProxyClient.GetSessionRecordingConfig(r.Context()) + if err != nil { + h.log.WithError(err).Error("Cannot retrieve SessionRecordingConfig.") + } else { + canJoinSessions = services.IsRecordAtProxy(recCfg.GetMode()) == false + } + webCfg := ui.WebConfig{ Auth: authSettings, CanJoinSessions: canJoinSessions,