Skip to content

Commit c6a4ab3

Browse files
committed
Fix SSO migration from production auth
1 parent 9f68b4a commit c6a4ab3

File tree

3 files changed

+58
-25
lines changed

3 files changed

+58
-25
lines changed

packages/amazonq/package.json

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,106 +1196,134 @@
11961196
"description": "AWS Contributed Icon",
11971197
"default": {
11981198
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1199-
"fontCharacter": "\\f1d1"
1199+
"fontCharacter": "\\f1d3"
12001200
}
12011201
},
12021202
"aws-mynah-MynahIconBlack": {
12031203
"description": "AWS Contributed Icon",
12041204
"default": {
12051205
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1206-
"fontCharacter": "\\f1d2"
1206+
"fontCharacter": "\\f1d4"
12071207
}
12081208
},
12091209
"aws-mynah-MynahIconWhite": {
12101210
"description": "AWS Contributed Icon",
12111211
"default": {
12121212
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1213-
"fontCharacter": "\\f1d3"
1213+
"fontCharacter": "\\f1d5"
12141214
}
12151215
},
12161216
"aws-mynah-logo": {
12171217
"description": "AWS Contributed Icon",
12181218
"default": {
12191219
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1220-
"fontCharacter": "\\f1d4"
1220+
"fontCharacter": "\\f1d6"
12211221
}
12221222
},
12231223
"aws-redshift-cluster": {
12241224
"description": "AWS Contributed Icon",
12251225
"default": {
12261226
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1227-
"fontCharacter": "\\f1d5"
1227+
"fontCharacter": "\\f1d7"
12281228
}
12291229
},
12301230
"aws-redshift-cluster-connected": {
12311231
"description": "AWS Contributed Icon",
12321232
"default": {
12331233
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1234-
"fontCharacter": "\\f1d6"
1234+
"fontCharacter": "\\f1d8"
12351235
}
12361236
},
12371237
"aws-redshift-database": {
12381238
"description": "AWS Contributed Icon",
12391239
"default": {
12401240
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1241-
"fontCharacter": "\\f1d7"
1241+
"fontCharacter": "\\f1d9"
12421242
}
12431243
},
12441244
"aws-redshift-redshift-cluster-connected": {
12451245
"description": "AWS Contributed Icon",
12461246
"default": {
12471247
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1248-
"fontCharacter": "\\f1d8"
1248+
"fontCharacter": "\\f1da"
12491249
}
12501250
},
12511251
"aws-redshift-schema": {
12521252
"description": "AWS Contributed Icon",
12531253
"default": {
12541254
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1255-
"fontCharacter": "\\f1d9"
1255+
"fontCharacter": "\\f1db"
12561256
}
12571257
},
12581258
"aws-redshift-table": {
12591259
"description": "AWS Contributed Icon",
12601260
"default": {
12611261
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1262-
"fontCharacter": "\\f1da"
1262+
"fontCharacter": "\\f1dc"
12631263
}
12641264
},
12651265
"aws-s3-bucket": {
12661266
"description": "AWS Contributed Icon",
12671267
"default": {
12681268
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1269-
"fontCharacter": "\\f1db"
1269+
"fontCharacter": "\\f1dd"
12701270
}
12711271
},
12721272
"aws-s3-create-bucket": {
12731273
"description": "AWS Contributed Icon",
12741274
"default": {
12751275
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1276-
"fontCharacter": "\\f1dc"
1276+
"fontCharacter": "\\f1de"
12771277
}
12781278
},
12791279
"aws-schemas-registry": {
12801280
"description": "AWS Contributed Icon",
12811281
"default": {
12821282
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1283-
"fontCharacter": "\\f1dd"
1283+
"fontCharacter": "\\f1e1"
12841284
}
12851285
},
12861286
"aws-schemas-schema": {
12871287
"description": "AWS Contributed Icon",
12881288
"default": {
12891289
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1290-
"fontCharacter": "\\f1de"
1290+
"fontCharacter": "\\f1e2"
12911291
}
12921292
},
12931293
"aws-stepfunctions-preview": {
1294+
"description": "AWS Contributed Icon",
1295+
"default": {
1296+
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1297+
"fontCharacter": "\\f1e3"
1298+
}
1299+
},
1300+
"aws-lambda-create-stack": {
1301+
"description": "AWS Contributed Icon",
1302+
"default": {
1303+
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1304+
"fontCharacter": "\\f1d1"
1305+
}
1306+
},
1307+
"aws-lambda-create-stack-light": {
1308+
"description": "AWS Contributed Icon",
1309+
"default": {
1310+
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1311+
"fontCharacter": "\\f1d2"
1312+
}
1313+
},
1314+
"aws-sagemaker-code-editor": {
12941315
"description": "AWS Contributed Icon",
12951316
"default": {
12961317
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
12971318
"fontCharacter": "\\f1df"
12981319
}
1320+
},
1321+
"aws-sagemaker-jupyter-lab": {
1322+
"description": "AWS Contributed Icon",
1323+
"default": {
1324+
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1325+
"fontCharacter": "\\f1e0"
1326+
}
12991327
}
13001328
},
13011329
"walkthroughs": [

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ export class AuthUtil implements IAuthProvider {
150150
this.session = new SsoLogin(this.profileName, this.lspAuth, this.eventEmitter)
151151
await this.session.restore()
152152
if (!this.isConnected()) {
153-
this.session?.logout()
153+
await this.session?.logout()
154154
// Try to restore an IAM session
155155
this.session = new IamLogin(this.profileName, this.lspAuth, this.eventEmitter)
156156
await this.session.restore()
157157
if (!this.isConnected()) {
158158
// If both fail, reset the session
159-
this.session?.logout()
159+
await this.session?.logout()
160160
}
161161
}
162162
}
@@ -181,12 +181,15 @@ export class AuthUtil implements IAuthProvider {
181181

182182
// Log in using SSO
183183
async loginSso(startUrl: string, region: string): Promise<GetSsoTokenResult | undefined> {
184-
let response: GetSsoTokenResult | undefined
185184
// Create SSO login session
186185
if (!this.isSsoSession()) {
187186
this.session = new SsoLogin(this.profileName, this.lspAuth, this.eventEmitter)
188187
}
189-
response = await (this.session as SsoLogin).login({ startUrl: startUrl, region: region, scopes: amazonQScopes })
188+
const response = await (this.session as SsoLogin).login({
189+
startUrl: startUrl,
190+
region: region,
191+
scopes: amazonQScopes,
192+
})
190193
await showAmazonQWalkthroughOnce()
191194
return response
192195
}
@@ -198,12 +201,11 @@ export class AuthUtil implements IAuthProvider {
198201
sessionToken?: string,
199202
roleArn?: string
200203
): Promise<GetIamCredentialResult | undefined> {
201-
let response: GetIamCredentialResult | undefined
202204
// Create IAM login session
203205
if (!this.isIamSession()) {
204206
this.session = new IamLogin(this.profileName, this.lspAuth, this.eventEmitter)
205207
}
206-
response = await (this.session as IamLogin).login({
208+
const response = await (this.session as IamLogin).login({
207209
accessKey: accessKey,
208210
secretKey: secretKey,
209211
sessionToken: sessionToken,
@@ -554,9 +556,10 @@ export class AuthUtil implements IAuthProvider {
554556
scopes: amazonQScopes,
555557
}
556558

557-
if (this.session instanceof SsoLogin) {
558-
await this.session.updateProfile(registrationKey)
559+
if (!this.isSsoSession()) {
560+
this.session = new SsoLogin(this.profileName, this.lspAuth, this.eventEmitter)
559561
}
562+
await (this.session as SsoLogin).updateProfile(registrationKey)
560563

561564
const cacheDir = getCacheDir()
562565

packages/core/src/test/credentials/auth2.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ describe('LanguageClientAuth', () => {
229229
const result = await auth.invalidateStsCredential(profileName)
230230

231231
sinon.assert.calledOnce(client.sendRequest)
232-
sinon.assert.calledWith(client.sendRequest, invalidateStsCredentialRequestType.method, { profileName: profileName })
232+
sinon.assert.calledWith(client.sendRequest, invalidateStsCredentialRequestType.method, {
233+
profileName: profileName,
234+
})
233235
sinon.assert.match(result, { success: true })
234236
})
235237
})
@@ -645,7 +647,7 @@ describe('IamLogin', () => {
645647
accessKeyId: 'encrypted-access-key',
646648
secretAccessKey: 'encrypted-secret-key',
647649
sessionToken: 'encrypted-session-token',
648-
}
650+
},
649651
},
650652
updateCredentialsParams: {
651653
data: 'credential-data',
@@ -823,4 +825,4 @@ describe('IamLogin', () => {
823825
sinon.assert.notCalled(fireEventSpy)
824826
})
825827
})
826-
})
828+
})

0 commit comments

Comments
 (0)