Skip to content

Commit

Permalink
Fix JSR310 serialization error when preparing login panel (#5216)
Browse files Browse the repository at this point in the history
If a user is somehow in the situtation where they have an `sso-session` defined, with a token in their SSO cache (either valid/invalid), then prepareBrowser fails since it tries to serialize the state of `connectionSettings` without the jackson-jsr310 module.

When using the IDE normally, this should not be possible because logout destroys the existing token and there is a prior check to see if user should be shown the chat panel / re-auth flow instead of the login browser

This is not intended behavior, so fix by configuring this to be an ignored field.
  • Loading branch information
rli authored Jan 9, 2025
1 parent 026056a commit 2f4877a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : "Fix issue where users are unable to login to Amazon Q if they have previously authenticated (#5214)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package software.aws.toolkits.jetbrains.core.credentials

import com.fasterxml.jackson.annotation.JsonIgnore
import com.intellij.openapi.Disposable
import com.intellij.openapi.util.Disposer
import software.aws.toolkits.core.TokenConnectionSettings
Expand Down Expand Up @@ -73,6 +74,7 @@ sealed class ManagedBearerSsoConnection(
region
)

@JsonIgnore
override fun getConnectionSettings(): TokenConnectionSettings = provider

override fun dispose() {
Expand All @@ -99,6 +101,7 @@ class DetectedDiskSsoSessionConnection(
region
)

@JsonIgnore
override fun getConnectionSettings(): TokenConnectionSettings = provider

override fun dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package software.aws.toolkits.jetbrains.core.credentials

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.testFramework.ProjectExtension
Expand Down Expand Up @@ -453,6 +454,22 @@ class DefaultToolkitAuthManagerTest {
}
}

@Test
fun `serializing LegacyManagedBearerSsoConnection does not include connectionSettings`() {
val profile = ManagedSsoProfile("us-east-1", "startUrl000", listOf("scopes"))
val connection = sut.createConnection(profile) as LegacyManagedBearerSsoConnection

assertThat(jacksonObjectMapper().writeValueAsString(connection)).doesNotContain("connectionSettings")
}

@Test
fun `serializing ProfileSsoManagedBearerSsoConnection does not include connectionSettings`() {
val profile = UserConfigSsoSessionProfile("sessionName", "us-east-1", "startUrl000", listOf("scopes"))
val connection = sut.createConnection(profile) as ProfileSsoManagedBearerSsoConnection

assertThat(jacksonObjectMapper().writeValueAsString(connection)).doesNotContain("connectionSettings")
}

private companion object {
@ExtendWith(ProjectExtension::class)
val projectRule = ProjectRule()
Expand Down

0 comments on commit 2f4877a

Please sign in to comment.