Skip to content

Commit 2f4877a

Browse files
authored
Fix JSR310 serialization error when preparing login panel (#5216)
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.
1 parent 026056a commit 2f4877a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Fix issue where users are unable to login to Amazon Q if they have previously authenticated (#5214)"
4+
}

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/ToolkitConnectionImpls.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

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

6+
import com.fasterxml.jackson.annotation.JsonIgnore
67
import com.intellij.openapi.Disposable
78
import com.intellij.openapi.util.Disposer
89
import software.aws.toolkits.core.TokenConnectionSettings
@@ -73,6 +74,7 @@ sealed class ManagedBearerSsoConnection(
7374
region
7475
)
7576

77+
@JsonIgnore
7678
override fun getConnectionSettings(): TokenConnectionSettings = provider
7779

7880
override fun dispose() {
@@ -99,6 +101,7 @@ class DetectedDiskSsoSessionConnection(
99101
region
100102
)
101103

104+
@JsonIgnore
102105
override fun getConnectionSettings(): TokenConnectionSettings = provider
103106

104107
override fun dispose() {

plugins/core/jetbrains-community/tst/software/aws/toolkits/jetbrains/core/credentials/DefaultToolkitAuthManagerTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

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

6+
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
67
import com.intellij.openapi.Disposable
78
import com.intellij.openapi.application.ApplicationManager
89
import com.intellij.testFramework.ProjectExtension
@@ -453,6 +454,22 @@ class DefaultToolkitAuthManagerTest {
453454
}
454455
}
455456

457+
@Test
458+
fun `serializing LegacyManagedBearerSsoConnection does not include connectionSettings`() {
459+
val profile = ManagedSsoProfile("us-east-1", "startUrl000", listOf("scopes"))
460+
val connection = sut.createConnection(profile) as LegacyManagedBearerSsoConnection
461+
462+
assertThat(jacksonObjectMapper().writeValueAsString(connection)).doesNotContain("connectionSettings")
463+
}
464+
465+
@Test
466+
fun `serializing ProfileSsoManagedBearerSsoConnection does not include connectionSettings`() {
467+
val profile = UserConfigSsoSessionProfile("sessionName", "us-east-1", "startUrl000", listOf("scopes"))
468+
val connection = sut.createConnection(profile) as ProfileSsoManagedBearerSsoConnection
469+
470+
assertThat(jacksonObjectMapper().writeValueAsString(connection)).doesNotContain("connectionSettings")
471+
}
472+
456473
private companion object {
457474
@ExtendWith(ProjectExtension::class)
458475
val projectRule = ProjectRule()

0 commit comments

Comments
 (0)