Skip to content
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

SSO logout now keeps profile in config file, popup removed #4968

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
Expand Up @@ -152,7 +152,7 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
QWebviewPanel.getInstance(project).browser?.prepareBrowser(BrowserState(FeatureId.AmazonQ))

// isQConnected alone is not robust and there is race condition (read/update connection states)
val component = if (isNewConnectionForQ || (isQConnected(project) && !isQExpired(project))) {
val component = if ((isQConnected(project) && !isQExpired(project))) {
LOG.debug { "returning Q-chat window; isQConnection=$isNewConnectionForQ; hasPinnedConnection=$isNewConnectionForQ" }
AmazonQToolWindow.getInstance(project).component
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import software.aws.toolkits.core.utils.info
import software.aws.toolkits.core.utils.warn
import software.aws.toolkits.jetbrains.core.credentials.pinning.FeatureWithPinnedConnection
import software.aws.toolkits.jetbrains.core.credentials.profiles.ProfileCredentialsIdentifierSso
import software.aws.toolkits.jetbrains.core.credentials.profiles.ProfileWatcher
import software.aws.toolkits.jetbrains.core.credentials.profiles.SsoSessionConstants.SSO_SESSION_SECTION_NAME
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenAuthState
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProvider
Expand Down Expand Up @@ -206,14 +207,9 @@ fun loginSso(

@Suppress("UnusedParameter")
fun logoutFromSsoConnection(project: Project?, connection: AwsBearerTokenConnection, callback: () -> Unit = {}) {
try {
ToolkitAuthManager.getInstance().deleteConnection(connection.id)
if (connection is ProfileSsoManagedBearerSsoConnection) {
deleteSsoConnection(connection)
}
} finally {
callback()
}
ToolkitAuthManager.getInstance().deleteConnection(connection.id)
ProfileWatcher.getInstance().forceRefresh()
callback()
}

fun lazyGetUnauthedBearerConnections() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ package software.aws.toolkits.jetbrains.core.credentials.actions
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.DumbAwareAction
import com.intellij.openapi.ui.MessageDialogBuilder
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
import software.aws.toolkits.jetbrains.core.credentials.ProfileSsoManagedBearerSsoConnection
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManagerListener
import software.aws.toolkits.jetbrains.core.credentials.logoutFromSsoConnection
import software.aws.toolkits.resources.AwsCoreBundle
Expand All @@ -17,15 +15,6 @@ import software.aws.toolkits.telemetry.UiTelemetry
class SsoLogoutAction(private val value: AwsBearerTokenConnection) : DumbAwareAction(AwsCoreBundle.message("credentials.individual_identity.signout")) {
override fun actionPerformed(e: AnActionEvent) {
UiTelemetry.click(e.project, "signOut")
if (value is ProfileSsoManagedBearerSsoConnection) {
val confirmDeletion = MessageDialogBuilder.okCancel(
AwsCoreBundle.message("gettingstarted.auth.idc.sign.out.confirmation.title"),
AwsCoreBundle.message("gettingstarted.auth.idc.sign.out.confirmation")
).yesText(AwsCoreBundle.message("general.confirm")).ask(e.project)
if (!confirmDeletion) {
return
}
}
logoutFromSsoConnection(e.project, value)
ApplicationManager.getApplication().messageBus.syncPublisher(
ToolkitConnectionManagerListener.TOPIC
Expand Down
Loading