Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Memorize and autofill users' last Sso login profile"
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export class AmazonQLoginWebview extends CommonAuthWebview {

async startEnterpriseSetup(startUrl: string, region: string): Promise<AuthError | undefined> {
getLogger().debug(`called startEnterpriseSetup() with startUrl: '${startUrl}', region: '${region}'`)
await globals.globalState.update('recentSso', {
startUrl: startUrl,
region: region,
})
return await this.ssoSetup('startCodeWhispererEnterpriseSetup', async () => {
this.storeMetricMetadata({
credentialStartUrl: startUrl,
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/login/webview/vue/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,13 @@ export abstract class CommonAuthWebview extends VueWebview {
return authEnabledFeatures.join(',')
}

getDefaultStartUrl() {
return DevSettings.instance.get('autofillStartUrl', '')
getDefaultSsoProfile(): { startUrl: string; region: string } {
const devSettings = DevSettings.instance.get('autofillStartUrl', '')
if (devSettings) {
return { startUrl: devSettings, region: 'us-east-1' }
}

return globals.globalState.tryGet('recentSso', Object, { startUrl: '', region: 'us-east-1' })
}

cancelAuthFlow() {
Expand Down
10 changes: 6 additions & 4 deletions packages/core/src/login/webview/vue/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export default defineComponent({
regions: [] as Region[],
startUrlError: '',
startUrlWarning: '',
selectedRegion: 'us-east-1',
selectedRegion: '',
startUrl: '',
app: this.app,
LoginOption,
Expand All @@ -353,7 +353,9 @@ export default defineComponent({
}
},
async created() {
this.startUrl = await this.getDefaultStartUrl()
const defaultSso = await this.getDefaultSso()
this.startUrl = defaultSso.startUrl
this.selectedRegion = defaultSso.region
await this.emitUpdate('created')
},

Expand Down Expand Up @@ -564,8 +566,8 @@ export default defineComponent({
async updateExistingStartUrls() {
this.existingStartUrls = (await client.listSsoConnections()).map((conn) => conn.startUrl)
},
async getDefaultStartUrl() {
return await client.getDefaultStartUrl()
async getDefaultSso() {
return await client.getDefaultSsoProfile()
},
handleHelpLinkClick() {
void client.emitUiClick('auth_helpLink')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { setContext } from '../../../../shared/vscode/setContext'
import { builderIdStartUrl } from '../../../../auth/sso/constants'
import { RegionProfile } from '../../../../codewhisperer/models/model'
import { ProfileSwitchIntent } from '../../../../codewhisperer/region/regionProfileManager'
import globals from '../../../../shared/extensionGlobals'

export class ToolkitLoginWebview extends CommonAuthWebview {
public override id: string = 'aws.toolkit.AmazonCommonAuth'
Expand All @@ -46,6 +47,10 @@ export class ToolkitLoginWebview extends CommonAuthWebview {
credentialStartUrl: startUrl,
isReAuth: false,
}
await globals.globalState.update('recentSso', {
startUrl: startUrl,
region: region,
})

if (this.isCodeCatalystLogin) {
return this.ssoSetup('startCodeCatalystSSOSetup', async () => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/shared/globalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export type globalKey =
| 'lastSelectedRegion'
| 'lastOsStartTime'
| 'recentCredentials'
| 'recentSso'
// List of regions enabled in AWS Explorer.
| 'region'
// TODO: implement this via `PromptSettings` instead of globalState.
Expand Down
Loading