Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in getWebConfig #11389

Merged
merged 5 commits into from
Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,33 +896,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
Expand All @@ -936,6 +926,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,
Expand Down