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

[v12] Use teleport-internal-join login when joining a Moderated Session from the UI #24018

Merged
merged 1 commit into from Apr 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/web/terminal.go
Expand Up @@ -290,13 +290,6 @@ func (t *TerminalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

// If the displayLogin is set then use it instead of the login name used in
// the SSH connection. This is specifically for the use case when joining
// a session to avoid displaying "-teleport-internal-join" as the username.
if t.displayLogin != "" {
t.sessionData.Login = t.displayLogin
}

sendError := func(errMsg string, err error, ws *websocket.Conn) {
envelope := &Envelope{
Version: defaults.WebsocketVersion,
Expand All @@ -308,7 +301,19 @@ func (t *TerminalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ws.WriteMessage(websocket.BinaryMessage, envelopeBytes)
}

sessionMetadataResponse, err := json.Marshal(siteSessionGenerateResponse{Session: t.sessionData})
var sessionMetadataResponse []byte

// If the displayLogin is set then use it in the session metadata instead of the
// login name used in the SSH connection. This is specifically for the use case
// when joining a session to avoid displaying "-teleport-internal-join" as the username.
if t.displayLogin != "" {
sessionDataTemp := t.sessionData
sessionDataTemp.Login = t.displayLogin
sessionMetadataResponse, err = json.Marshal(siteSessionGenerateResponse{Session: sessionDataTemp})
} else {
sessionMetadataResponse, err = json.Marshal(siteSessionGenerateResponse{Session: t.sessionData})
}

if err != nil {
sendError("unable to marshal session response", err, ws)
return
Expand Down