Skip to content

Commit

Permalink
Fix issue where unauthenticated logins caused 401 because refresh cau…
Browse files Browse the repository at this point in the history
…sed new credentials to be created (#2752)

Co-authored-by: Matt Creaser <[email protected]>
Co-authored-by: JoonWon Choi <[email protected]>
  • Loading branch information
3 people authored Apr 11, 2024
1 parent 4bea6d4 commit fd2fff9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ internal object AuthorizationCognitoActions : AuthorizationActions {
RefreshSessionEvent.EventType.RefreshUserPoolTokens(amplifyCredential.signedInData)
)
is AmplifyCredential.IdentityPool -> RefreshSessionEvent(
RefreshSessionEvent.EventType.RefreshUnAuthSession(LoginsMapProvider.UnAuthLogins())
RefreshSessionEvent.EventType.RefreshUnAuthSession(
amplifyCredential.identityId,
LoginsMapProvider.UnAuthLogins()
)
)
is AmplifyCredential.IdentityPoolFederated -> {
AuthorizationEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class RefreshSessionEvent(val eventType: EventType, override val time:
sealed class EventType {
data class RefreshUserPoolTokens(val signedInData: SignedInData) : EventType()
data class RefreshAuthSession(val signedInData: SignedInData, val logins: LoginsMapProvider) : EventType()
data class RefreshUnAuthSession(val logins: LoginsMapProvider) : EventType()
data class RefreshUnAuthSession(val identityId: String, val logins: LoginsMapProvider) : EventType()
data class Refreshed(val signedInData: SignedInData) : EventType()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,19 @@ internal sealed class RefreshSessionState : State {
StateResolution(RefreshingUserPoolTokens(refreshSessionEvent.signedInData), listOf(action))
}
is RefreshSessionEvent.EventType.RefreshUnAuthSession -> {
val action = fetchAuthSessionActions.refreshAuthSessionAction(refreshSessionEvent.logins)
StateResolution(RefreshingUnAuthSession(FetchAuthSessionState.NotStarted()), listOf(action))
val action = fetchAuthSessionActions.fetchAWSCredentialsAction(
refreshSessionEvent.identityId,
refreshSessionEvent.logins
)
StateResolution(
RefreshingUnAuthSession(
FetchAuthSessionState.FetchingAWSCredentials(
refreshSessionEvent.identityId,
refreshSessionEvent.logins
)
),
listOf(action)
)
}
else -> defaultResolution
}
Expand Down

0 comments on commit fd2fff9

Please sign in to comment.