Skip to content
Merged
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
13 changes: 12 additions & 1 deletion packages/pam/session/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func uploadTokenFilePath(sessionID string) string {
return filepath.Join(GetSessionRecordingDir(), "chunks", sessionID+".uploadtoken.enc")
}

const AwsIamAuthMethod = "aws-iam"

const awsIamCredentialTTL = 10 * time.Minute

type PAMCredentials struct {
AuthMethod string
Username string
Expand Down Expand Up @@ -203,10 +207,17 @@ func (cm *CredentialsManager) GetPAMSessionCredentials(sessionId string, expiryT
PolicyRules: response.PolicyRules,
}

cacheExpiry := expiryTime
if credentials.AuthMethod == AwsIamAuthMethod {
if tokenExpiry := time.Now().Add(awsIamCredentialTTL); tokenExpiry.Before(cacheExpiry) {
cacheExpiry = tokenExpiry
}
}

cm.cacheMutex.Lock()
cm.credentialsCache[sessionId] = &cachedCredentials{
credentials: credentials,
expiresAt: expiryTime,
expiresAt: cacheExpiry,
}
cm.cacheMutex.Unlock()

Expand Down
Loading