-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change introduces a more managed approach to implementing Credentials Providers for the toolkit. The goal is to make it easier to onboard support for new credentials types moving forward. This design is very similar to the approach taken in the AWS Toolkit for JetBrains. Integrating this new system brought about some functional changes and bug fixes. New Behavior: * added logging for Shared Credentials profiles detection and validation * credentials are now shown by "credential provider id" instead of profile name (example: `profile:default`) * whenever users run the "Connect to AWS" command, the Toolkit's list of available credentials providers is refreshed (eg: pulling the latest updates from the shared credentials files) * Credentials are cached and re-used for the duration of a toolkit session. When logging in, if a Shared Credentials Profile has been modified since it was cached, the updated version of the profile will be used instead of the cached version now. * updated the "Invalid Credentials" notification, and added a button guiding users to the logs
- Loading branch information
1 parent
f91693d
commit 86e0604
Showing
38 changed files
with
1,522 additions
and
467 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
.changes/next-release/Bug Fix-7c5a454e-97e7-4f9e-91b7-c215d978f3c8.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type": "Bug Fix", | ||
"description": "Fixed an issue where invalid credentials were reused until VS Code was closed and re-opened, even if the credentials source was updated. It is no longer necessary to restart VS Code. (#705)" | ||
} |
4 changes: 4 additions & 0 deletions
4
.changes/next-release/Feature-1c091dfc-c519-4fa1-8f1a-7ab8d7db214b.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type": "Feature", | ||
"description": "When credentials are invalid a notification is shown. To help diagnose these situations, a button was added to the notification that can open the logs." | ||
} |
4 changes: 4 additions & 0 deletions
4
.changes/next-release/Feature-681f79db-6ef7-4172-9f5a-52b42c93ede6.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type": "Feature", | ||
"description": "When changes are made to Shared Credentials files, they will be picked up by the Toolkit the next time credentials are selected during the 'Connect to AWS' command." | ||
} |
4 changes: 4 additions & 0 deletions
4
.changes/next-release/Feature-8fac7fd9-cdfb-4a82-8dba-31a1da5197b7.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type": "Feature", | ||
"description": "Credentials were previously shown by their Shared Credentials profile names. They are now displayed in a \"type:name\" format, to better indicate the type of Credentials being used, and to support additional Credentials types in the future. Shared Credentials are shown with the type \"profile\"." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/*! | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CredentialsProviderId } from './credentialsProviderId' | ||
|
||
export interface CredentialsProvider { | ||
getCredentialsProviderId(): CredentialsProviderId | ||
getDefaultRegion(): string | undefined | ||
getHashCode(): string | ||
getCredentials(): Promise<AWS.Credentials> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*! | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CredentialsProvider } from './credentialsProvider' | ||
import { CredentialsProviderId, isEqual } from './credentialsProviderId' | ||
|
||
/** | ||
* Responsible for producing CredentialsProvider objects for a Credential Type | ||
*/ | ||
export interface CredentialsProviderFactory { | ||
getCredentialType(): string | ||
listProviders(): CredentialsProvider[] | ||
getProvider(credentialsProviderId: CredentialsProviderId): CredentialsProvider | undefined | ||
refresh(): Promise<void> | ||
} | ||
|
||
export abstract class BaseCredentialsProviderFactory<T extends CredentialsProvider> | ||
implements CredentialsProviderFactory { | ||
protected providers: T[] = [] | ||
public abstract getCredentialType(): string | ||
|
||
public listProviders(): T[] { | ||
return [...this.providers] | ||
} | ||
|
||
public getProvider(credentialsProviderId: CredentialsProviderId): CredentialsProvider | undefined { | ||
for (const provider of this.providers) { | ||
if (isEqual(provider.getCredentialsProviderId(), credentialsProviderId)) { | ||
return provider | ||
} | ||
} | ||
|
||
return undefined | ||
} | ||
|
||
public abstract async refresh(): Promise<void> | ||
|
||
protected addProvider(provider: T) { | ||
this.providers.push(provider) | ||
} | ||
|
||
protected removeProvider(provider: T) { | ||
this.providers = this.providers.filter(x => x !== provider) | ||
} | ||
|
||
protected resetProviders() { | ||
this.providers = [] | ||
} | ||
} |
Oops, something went wrong.