Skip to content

Commit

Permalink
Add access requests to UserMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
espadolini committed Jan 12, 2022
1 parent 517a021 commit 78d1ffd
Show file tree
Hide file tree
Showing 6 changed files with 419 additions and 416 deletions.
802 changes: 401 additions & 401 deletions api/types/events/events.pb.go

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions api/types/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ message UserMetadata {

// AWSRoleARN is AWS IAM role user assumes when accessing AWS console.
string AWSRoleARN = 4 [ (gogoproto.jsontag) = "aws_role_arn,omitempty" ];

// AccessRequests are the IDs of access requests created by the user
repeated string AccessRequests = 5 [ (gogoproto.jsontag) = "access_requests,omitempty" ];
}

// Server is a server metadata
Expand Down Expand Up @@ -131,6 +134,9 @@ message KubernetesPodMetadata {

// SessionStart is a session start event
message SessionStart {
reserved 11;
reserved "AccessRequests";

// Metadata is a common event metadata
Metadata Metadata = 1
[ (gogoproto.nullable) = false, (gogoproto.embed) = true, (gogoproto.jsontag) = "" ];
Expand Down Expand Up @@ -168,9 +174,6 @@ message SessionStart {

// SessionRecording is the type of session recording.
string SessionRecording = 10 [ (gogoproto.jsontag) = "session_recording,omitempty" ];

// AccessRequests are the IDs of access requests created by the user
repeated string AccessRequests = 11 [ (gogoproto.jsontag) = "access_requests,omitempty" ];
}

// SessionJoin emitted when another user joins a session
Expand Down
10 changes: 5 additions & 5 deletions lib/kube/proxy/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ func (c *authContext) eventClusterMeta() apievents.KubernetesClusterMetadata {
}

func (c *authContext) eventUserMeta() apievents.UserMetadata {
return apievents.UserMetadata{
User: c.User.GetName(),
Login: c.User.GetName(),
Impersonator: c.Identity.GetIdentity().Impersonator,
}
name := c.User.GetName()
meta := c.Identity.GetIdentity().GetUserMetadata()
meta.User = name
meta.Login = name
return meta
}

type dialFunc func(ctx context.Context, network, addr, serverID string) (net.Conn, error)
Expand Down
7 changes: 4 additions & 3 deletions lib/srv/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,10 @@ func (c *ServerContext) ExecCommand() (*ExecCommand, error) {

func (id *IdentityContext) GetUserMetadata() apievents.UserMetadata {
return apievents.UserMetadata{
Login: id.Login,
User: id.TeleportUser,
Impersonator: id.Impersonator,
Login: id.Login,
User: id.TeleportUser,
Impersonator: id.Impersonator,
AccessRequests: id.ActiveRequests,
}
}

Expand Down
2 changes: 0 additions & 2 deletions lib/srv/sess.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ func (s *session) startInteractive(ch ssh.Channel, ctx *ServerContext) error {
},
TerminalSize: params.Serialize(),
SessionRecording: ctx.SessionRecordingConfig.GetMode(),
AccessRequests: ctx.Identity.ActiveRequests,
}

// Local address only makes sense for non-tunnel nodes.
Expand Down Expand Up @@ -904,7 +903,6 @@ func (s *session) startExec(channel ssh.Channel, ctx *ServerContext) error {
RemoteAddr: ctx.ServerConn.RemoteAddr().String(),
},
SessionRecording: ctx.SessionRecordingConfig.GetMode(),
AccessRequests: ctx.Identity.ActiveRequests,
}
// Local address only makes sense for non-tunnel nodes.
if !ctx.srv.UseTunnel() {
Expand Down
5 changes: 3 additions & 2 deletions lib/tlsca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,9 @@ func FromSubject(subject pkix.Name, expires time.Time) (*Identity, error) {

func (id Identity) GetUserMetadata() events.UserMetadata {
return events.UserMetadata{
User: id.Username,
Impersonator: id.Impersonator,
User: id.Username,
Impersonator: id.Impersonator,
AccessRequests: id.ActiveRequests,
}
}

Expand Down

0 comments on commit 78d1ffd

Please sign in to comment.