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

Fix issue where unauthenticated logins caused 401 because refresh caused new credentials to be created #2752

Merged
merged 5 commits into from
Apr 11, 2024
Merged
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 @@ -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
Loading