-
Notifications
You must be signed in to change notification settings - Fork 250
Added notification when starting up to an invalid credential, or when selecting an invalid credential #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… selecting an invalid credential
Codecov Report
@@ Coverage Diff @@
## master #635 +/- ##
===========================================
- Coverage 52.07% 45.3% -6.78%
+ Complexity 486 446 -40
===========================================
Files 138 138
Lines 4280 4322 +42
Branches 623 629 +6
===========================================
- Hits 2229 1958 -271
- Misses 1800 2136 +336
+ Partials 251 228 -23
Continue to review full report at Codecov.
|
@@ -31,6 +33,20 @@ abstract class ToolkitCredentialsProvider : AwsCredentialsProvider { | |||
override fun hashCode(): Int = id.hashCode() | |||
|
|||
override fun toString(): String = "${this::class.simpleName}(id='$id')" | |||
|
|||
open fun isValid(sdkHttpClient: SdkHttpClient): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the parameter and just use AwsSdkClient.getInstance().sdkHttpClient
? I don't see the reason for using other SDK client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in core, which doesn't have a reference to jetbrains-core
, where AwsSdkClient
resides
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, gotcha
title = message("credentials.invalid.title"), | ||
content = message("credentials.invalid.notification", credentialsProvider.displayName), | ||
listener = NotificationListener { notification, _ -> | ||
ActionManager.getInstance().getAction("aws.settings.upsertCredentials").actionPerformed(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to just add this Action to the notification using Notification.addAction
. That way, you don't need the listener.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use NotificationAction
as a wrapper of the CreateOrUpdateCredentialProfilesAction
@@ -56,6 +57,9 @@ class CreateOrUpdateCredentialProfilesAction @TestOnly constructor( | |||
localFileSystem.refreshFiles(listOf(virtualFile), false, false) { | |||
fileEditorManager.openTextEditor(OpenFileDescriptor(project, virtualFile), true) | |||
?: throw RuntimeException(message("credentials.could_not_open", file)) | |||
|
|||
// TODO : remove message (and localized string) when credentials auto-refreshing is supported | |||
notifyInfo("", message("credentials.notification.restart.ide")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to provide a title for this info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From this message, it's not clear to tell what the credentials are, although it could be inferred from the context. Maybe we should change the credentials
to AWS credentials
to be more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWS credential
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about After modifying AWS credentials, you will need to restart the IDE for the toolkit to use your changes.
?
@@ -107,7 +110,9 @@ class DefaultProjectAccountSettingsManager(private val project: Project) : | |||
@Throws(CredentialProviderNotFound::class) | |||
get() = activeProfileInternal | |||
?: tryOrNull { | |||
getCredentialProviderOrNull("${ProfileToolkitCredentialsProviderFactory.TYPE}:default") | |||
getCredentialProviderOrNull(ProfileToolkitCredentialsProviderFactory.DEFAULT_PROFILE_DISPLAY_NAME) | |||
}?.takeIf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will trigger MFA for loading of certain UIs that dont need it yet such as editing a run config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does my change trigger MFA where the existing code does not?
@@ -130,7 +135,22 @@ class DefaultProjectAccountSettingsManager(private val project: Project) : | |||
|
|||
override fun loadState(state: AccountState) { | |||
activeRegionInternal = regionProvider.lookupRegionById(state.activeRegion) | |||
activeProfileInternal = state.activeProfile?.let { getCredentialProviderOrNull(it) } | |||
state.activeProfile?.let { getCredentialProviderOrNull(it) }?.run { | |||
if (this.isValid(AwsSdkClient.getInstance().sdkHttpClient)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also triggers MFA on IDE start...maybe thats okay?
this.message ?: "${this::class.java.name}${this.stackTrace?.joinToString("\n", prefix = "\n")}", | ||
NotificationType.ERROR | ||
), project | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: can we move these to the util file as well, so that all the notify warn
can share the same behavior.
Types of changes
Description
Added STS getCallerIdentity validation
Motivation and Context
Related Issue(s)
#578
Testing
Screenshots (if appropriate)
Checklist
gradlew check
succeedsLicense
I confirm that my contribution is made under the terms of the Apache 2.0 license.