Skip to content

Add FileTransferRequests to session for moderated scp#23875

Merged
avatus merged 1 commit intomasterfrom
michaelmyers/moderated_session_scp_check
Apr 6, 2023
Merged

Add FileTransferRequests to session for moderated scp#23875
avatus merged 1 commit intomasterfrom
michaelmyers/moderated_session_scp_check

Conversation

@avatus
Copy link
Copy Markdown
Contributor

@avatus avatus commented Mar 30, 2023

Part of #23546

This will add a fileTransferRequest to a session and allow environment variables to be passed from the webUI in order to validate a request that happens "outside" the moderated session (via HTTP request).

The next PR to follow will be the webui/terminal updates that include the approval process.

Note: The fileTransferRequest struct varies slightly from the RFD as I found most of the fields unused outside of the approval process. This will most likely be expanded to closer match in the RFD in the subsequent PR.

@github-actions github-actions Bot requested review from fspmarshall and mdwn March 30, 2023 21:28
mdwn
mdwn previously requested changes Mar 31, 2023
Copy link
Copy Markdown
Contributor

@mdwn mdwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two small things. Feel free to push back!

Comment thread lib/client/client.go
Comment on lines +1760 to +1817
// File transfers in a moderated session require these two variablesto check for
// approval on the ssh server. If they exist in the context, set them in our env vars
if moderatedSessionID, ok := ctx.Value(scp.ModeratedSession).(string); ok {
s.Setenv(ctx, scp.ModeratedSession, moderatedSessionID)
}
if fileTransferRequestID, ok := ctx.Value(scp.FileTransferRequest).(string); ok {
s.Setenv(ctx, scp.FileTransferRequest, fileTransferRequestID)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should we add an error here if only one of these two vars is supplied?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I won't do it here tho, I think in the api handler is better to catch it early on. Thanks!

Comment thread lib/srv/sess.go Outdated
return sess.term.GetWinSize()
}

func (s *SessionRegistry) isApprovedFileTransfer(ctx context.Context, scx *ServerContext) (bool, error) {
Copy link
Copy Markdown
Contributor

@mdwn mdwn Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some tests for this function since it seems complex enough to warrant it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave the test a shot although the test seemed to be a bit complex (maybe unavoidable?). Happy for input

Copy link
Copy Markdown
Contributor

@fspmarshall fspmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgmt once existing feedback is addressed.

@AntonAM AntonAM self-requested a review April 5, 2023 16:25
Comment thread lib/sshutils/scp/http.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better name would be FileTransferRequestID to more accurately show what it is and be consistent with the rest of the naming. (Same for ModeratedSession)

Part of #23546

This will add a fileTransferRequest to a session and allow environment variables to be passed from the webUI in order to validate a request that happens "outside" the moderated session (via HTTP request).
@avatus avatus force-pushed the michaelmyers/moderated_session_scp_check branch from 5ffe88e to a5e8a18 Compare April 6, 2023 00:11
@avatus avatus enabled auto-merge April 6, 2023 00:12
@zmb3 zmb3 requested a review from mdwn April 6, 2023 17:45
@r0mant r0mant dismissed mdwn’s stale review April 6, 2023 18:21

Dismissing so the PR can be merged.

@avatus avatus added this pull request to the merge queue Apr 6, 2023
Merged via the queue into master with commit 50826a1 Apr 6, 2023
@avatus avatus deleted the michaelmyers/moderated_session_scp_check branch April 6, 2023 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants