Skip to content

Commit

Permalink
include access request metadata in app.session.start events (#48805)
Browse files Browse the repository at this point in the history
  • Loading branch information
rudream authored Nov 12, 2024
1 parent bd3cfc7 commit 7adada0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/auth/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,17 @@ func (a *Server) CreateAppSessionFromReq(ctx context.Context, req NewAppSessionR
log.Debugf("Generated application web session for %v with TTL %v.", req.User, req.SessionTTL)
UserLoginCount.Inc()

userMetadata := req.Identity.GetUserMetadata()
// Extract the identity of the user from the certificate, this will include metadata from any actively assumed access requests.
certificate, err := tlsca.ParseCertificatePEM(session.GetTLSCert())
if err != nil {
return nil, trace.Wrap(err)
}
identity, err := tlsca.FromSubject(certificate.Subject, certificate.NotAfter)
if err != nil {
return nil, trace.Wrap(err)
}

userMetadata := identity.GetUserMetadata()
userMetadata.User = session.GetUser()
userMetadata.AWSRoleARN = req.AWSRoleARN

Expand Down

0 comments on commit 7adada0

Please sign in to comment.