Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 2 additions & 8 deletions lib/srv/authhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,6 @@ func (h *AuthHandlers) CheckX11Forward(ctx *ServerContext) error {
return trace.AccessDenied("x11 forwarding not permitted")
}

func (h *AuthHandlers) CheckFileCopying(ctx *ServerContext) error {
if ctx.Identity.AccessPermit != nil && ctx.Identity.AccessPermit.SshFileCopy {
return nil
}

return trace.Wrap(errRoleFileCopyingNotPermitted)
}

// CheckPortForward checks if port forwarding is allowed for the users RoleSet.
func (h *AuthHandlers) CheckPortForward(addr string, ctx *ServerContext, requestedMode decisionpb.SSHPortForwardMode) error {
if ctx.Identity.AccessPermit == nil {
Expand Down Expand Up @@ -781,6 +773,7 @@ type proxyingPermit struct {
PrivateKeyPolicy keys.PrivateKeyPolicy
LockTargets []types.LockTarget
MaxConnections int64
SSHFileCopy bool
DisconnectExpiredCert time.Time
MappedRoles []string
SessionRecordingMode constants.SessionRecordingMode
Expand Down Expand Up @@ -826,6 +819,7 @@ func (a *ahLoginChecker) evaluateProxying(ident *sshca.Identity, ca types.CertAu
PrivateKeyPolicy: privateKeyPolicy,
LockTargets: lockTargets,
MaxConnections: accessChecker.MaxConnections(),
SSHFileCopy: accessChecker.CanCopyFiles(),
DisconnectExpiredCert: getDisconnectExpiredCertFromSSHIdentity(accessChecker, authPref, ident),
MappedRoles: accessInfo.Roles,
SessionRecordingMode: accessChecker.SessionRecordingMode(constants.SessionRecordingServiceSSH),
Expand Down
5 changes: 5 additions & 0 deletions lib/srv/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,11 @@ func (c *ServerContext) CheckFileCopyingAllowed() error {
return nil
}

// check if proxying permit is defined and authorizes file copying
if permit := c.Identity.ProxyingPermit; permit != nil && permit.SSHFileCopy {
return nil
}

return trace.Wrap(errRoleFileCopyingNotPermitted)
}

Expand Down
18 changes: 18 additions & 0 deletions lib/srv/ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestCheckSFTPAllowed(t *testing.T) {
name string
nodeAllowFileCopying bool
permit *decisionpb.SSHAccessPermit
proxyingPermit *proxyingPermit
sessionPolicies []*types.SessionRequirePolicy
expectedErr error
}{
Expand Down Expand Up @@ -81,6 +82,22 @@ func TestCheckSFTPAllowed(t *testing.T) {
},
expectedErr: nil,
},
{
name: "proxying role disallowed",
nodeAllowFileCopying: true,
proxyingPermit: &proxyingPermit{
SSHFileCopy: false,
},
expectedErr: errRoleFileCopyingNotPermitted,
},
{
name: "proxying role allowed",
nodeAllowFileCopying: true,
proxyingPermit: &proxyingPermit{
SSHFileCopy: true,
},
expectedErr: nil,
},
{
name: "moderated sessions enforced",
nodeAllowFileCopying: true,
Expand Down Expand Up @@ -125,6 +142,7 @@ func TestCheckSFTPAllowed(t *testing.T) {
)

ctx.Identity.AccessPermit = tt.permit
ctx.Identity.ProxyingPermit = tt.proxyingPermit

err := ctx.CheckSFTPAllowed(nil)
if tt.expectedErr == nil {
Expand Down
Loading