Skip to content

Commit fd2fff9

Browse files
marcoatblueowlmattcreaserJoonWon Choi
authored
Fix issue where unauthenticated logins caused 401 because refresh caused new credentials to be created (#2752)
Co-authored-by: Matt Creaser <[email protected]> Co-authored-by: JoonWon Choi <[email protected]>
1 parent 4bea6d4 commit fd2fff9

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/actions/AuthorizationCognitoActions.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ internal object AuthorizationCognitoActions : AuthorizationActions {
105105
RefreshSessionEvent.EventType.RefreshUserPoolTokens(amplifyCredential.signedInData)
106106
)
107107
is AmplifyCredential.IdentityPool -> RefreshSessionEvent(
108-
RefreshSessionEvent.EventType.RefreshUnAuthSession(LoginsMapProvider.UnAuthLogins())
108+
RefreshSessionEvent.EventType.RefreshUnAuthSession(
109+
amplifyCredential.identityId,
110+
LoginsMapProvider.UnAuthLogins()
111+
)
109112
)
110113
is AmplifyCredential.IdentityPoolFederated -> {
111114
AuthorizationEvent(

aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/events/RefreshSessionEvent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal class RefreshSessionEvent(val eventType: EventType, override val time:
2424
sealed class EventType {
2525
data class RefreshUserPoolTokens(val signedInData: SignedInData) : EventType()
2626
data class RefreshAuthSession(val signedInData: SignedInData, val logins: LoginsMapProvider) : EventType()
27-
data class RefreshUnAuthSession(val logins: LoginsMapProvider) : EventType()
27+
data class RefreshUnAuthSession(val identityId: String, val logins: LoginsMapProvider) : EventType()
2828
data class Refreshed(val signedInData: SignedInData) : EventType()
2929
}
3030

aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/states/RefreshSessionState.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,19 @@ internal sealed class RefreshSessionState : State {
8787
StateResolution(RefreshingUserPoolTokens(refreshSessionEvent.signedInData), listOf(action))
8888
}
8989
is RefreshSessionEvent.EventType.RefreshUnAuthSession -> {
90-
val action = fetchAuthSessionActions.refreshAuthSessionAction(refreshSessionEvent.logins)
91-
StateResolution(RefreshingUnAuthSession(FetchAuthSessionState.NotStarted()), listOf(action))
90+
val action = fetchAuthSessionActions.fetchAWSCredentialsAction(
91+
refreshSessionEvent.identityId,
92+
refreshSessionEvent.logins
93+
)
94+
StateResolution(
95+
RefreshingUnAuthSession(
96+
FetchAuthSessionState.FetchingAWSCredentials(
97+
refreshSessionEvent.identityId,
98+
refreshSessionEvent.logins
99+
)
100+
),
101+
listOf(action)
102+
)
92103
}
93104
else -> defaultResolution
94105
}

0 commit comments

Comments
 (0)