Skip to content

Commit 5830716

Browse files
committed
Add session tokens to auth2 logic
1 parent 4d2b8b0 commit 5830716

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/core/src/auth/auth2.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class LanguageClientAuth {
273273
export abstract class BaseLogin {
274274
protected connectionState: AuthState = 'notConnected'
275275
protected cancellationToken: CancellationTokenSource | undefined
276-
protected _data: { startUrl?: string; region?: string; accessKey?: string; secretKey?: string } | undefined
276+
protected _data: { startUrl?: string; region?: string; accessKey?: string; secretKey?: string; sessionToken?: string } | undefined
277277

278278
constructor(
279279
public readonly profileName: string,
@@ -525,6 +525,7 @@ export class IamLogin extends BaseLogin {
525525
this._data = {
526526
accessKey: opts.accessKey,
527527
secretKey: opts.secretKey,
528+
sessionToken: opts.sessionToken
528529
}
529530
}
530531

@@ -542,6 +543,7 @@ export class IamLogin extends BaseLogin {
542543
this._data = {
543544
accessKey: credentials.aws_access_key_id,
544545
secretKey: credentials.aws_secret_access_key,
546+
sessionToken: credentials.aws_session_token
545547
}
546548
}
547549
try {

packages/core/src/codewhisperer/util/authUtil.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface IAuthProvider {
6464
getToken(): Promise<string>
6565
getIamCredential(): Promise<IamCredentials>
6666
readonly profileName: string
67-
readonly connection?: { startUrl?: string; region?: string; accessKey?: string; secretKey?: string }
67+
readonly connection?: { startUrl?: string; region?: string; accessKey?: string; secretKey?: string; sessionToken?: string }
6868
}
6969

7070
/**
@@ -132,12 +132,13 @@ export class AuthUtil implements IAuthProvider {
132132
this.session = new SsoLogin(this.profileName, this.lspAuth, this.eventEmitter)
133133
await this.session.restore()
134134
if (!this.isConnected()) {
135+
this.session?.logout()
135136
// Try to restore an IAM session
136137
this.session = new IamLogin(this.profileName, this.lspAuth, this.eventEmitter)
137138
await this.session.restore()
138139
if (!this.isConnected()) {
139140
// If both fail, reset the session
140-
this.session = undefined
141+
this.session?.logout()
141142
}
142143
}
143144
}

0 commit comments

Comments
 (0)