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(auth): Remove authenticationFlowType from Gen2 config #2781

Merged
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 @@ -177,7 +177,7 @@ data class AuthConfiguration internal constructor(
),
identityPool = identityPool,
oauth = oauth,
authFlowType = auth.authenticationFlowType.toConfigType(),
authFlowType = AuthFlowType.USER_SRP_AUTH,
signUpAttributes = auth.standardRequiredAttributes,
usernameAttributes = auth.usernameAttributes.map { it.toConfigType() },
verificationMechanisms = auth.userVerificationTypes.map { it.toConfigType() },
Expand Down Expand Up @@ -223,11 +223,6 @@ data class AuthConfiguration internal constructor(
func(it)
}

private fun AmplifyOutputsData.Auth.AuthenticationFlowType.toConfigType() = when (this) {
AmplifyOutputsData.Auth.AuthenticationFlowType.USER_SRP_AUTH -> AuthFlowType.USER_SRP_AUTH
AmplifyOutputsData.Auth.AuthenticationFlowType.CUSTOM_AUTH -> AuthFlowType.CUSTOM_AUTH
}

private fun AmplifyOutputsData.Auth.UsernameAttributes.toConfigType() = when (this) {
AmplifyOutputsData.Auth.UsernameAttributes.Email -> UsernameAttribute.Email
AmplifyOutputsData.Auth.UsernameAttributes.PhoneNumber -> UsernameAttribute.PhoneNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ class AuthConfigurationTest {
userPoolId = "userpool"
userPoolClientId = "userpool-client"
identityPoolId = "identity-pool"
authenticationFlowType = AmplifyOutputsData.Auth.AuthenticationFlowType.CUSTOM_AUTH
passwordPolicy {
requireLowercase = true
requireSymbols = true
Expand All @@ -203,7 +202,7 @@ class AuthConfigurationTest {

val configuration = AuthConfiguration.from(data)

configuration.authFlowType shouldBe AuthFlowType.CUSTOM_AUTH
configuration.authFlowType shouldBe AuthFlowType.USER_SRP_AUTH
configuration.userPool.shouldNotBeNull().run {
region shouldBe "test-region"
poolId shouldBe "userpool"
Expand Down Expand Up @@ -243,13 +242,12 @@ class AuthConfigurationTest {
awsRegion = "test-region"
userPoolId = "userpool"
userPoolClientId = "userpool-client"
authenticationFlowType = AmplifyOutputsData.Auth.AuthenticationFlowType.CUSTOM_AUTH
}
}

val configuration = AuthConfiguration.from(data)

configuration.authFlowType shouldBe AuthFlowType.CUSTOM_AUTH
configuration.authFlowType shouldBe AuthFlowType.USER_SRP_AUTH
configuration.userPool.shouldNotBeNull().run {
region shouldBe "test-region"
poolId shouldBe "userpool"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.amplifyframework.AmplifyException
import com.amplifyframework.annotations.InternalAmplifyApi
import com.amplifyframework.auth.AuthUserAttributeKey
import com.amplifyframework.core.configuration.AmplifyOutputsData.AmazonPinpointChannels
import com.amplifyframework.core.configuration.AmplifyOutputsData.Auth.AuthenticationFlowType
import com.amplifyframework.core.configuration.AmplifyOutputsData.Auth.MfaConfiguration
import com.amplifyframework.core.configuration.AmplifyOutputsData.Auth.MfaMethods
import com.amplifyframework.core.configuration.AmplifyOutputsData.Auth.Oauth.IdentityProviders
Expand Down Expand Up @@ -66,7 +65,6 @@ interface AmplifyOutputsData {
@InternalAmplifyApi
interface Auth {
val awsRegion: String
val authenticationFlowType: AuthenticationFlowType
val userPoolId: String
val userPoolClientId: String
val identityPoolId: String?
Expand Down Expand Up @@ -114,9 +112,6 @@ interface AmplifyOutputsData {
}
}

@InternalAmplifyApi
enum class AuthenticationFlowType { USER_SRP_AUTH, CUSTOM_AUTH }

@InternalAmplifyApi
@Serializable
enum class UsernameAttributes {
Expand Down Expand Up @@ -282,7 +277,6 @@ internal data class AmplifyOutputsDataImpl(
@Serializable
data class Auth(
override val awsRegion: String,
override val authenticationFlowType: AuthenticationFlowType = AuthenticationFlowType.USER_SRP_AUTH,
override val userPoolId: String,
override val userPoolClientId: String,
override val identityPoolId: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class AmplifyOutputsDataTest {
val json = createJson(
Keys.auth to mapOf(
Keys.region to "us-east-1",
Keys.authFlowType to AmplifyOutputsData.Auth.AuthenticationFlowType.USER_SRP_AUTH.name,
Keys.userPoolId to "user-pool",
Keys.userPoolClientId to "user-pool-client",
Keys.identityPoolId to "identity-pool",
Expand Down Expand Up @@ -106,7 +105,6 @@ class AmplifyOutputsDataTest {
outputs.auth.shouldNotBeNull()
outputs.auth?.run {
awsRegion shouldBe "us-east-1"
authenticationFlowType shouldBe AmplifyOutputsData.Auth.AuthenticationFlowType.USER_SRP_AUTH
userPoolId shouldBe "user-pool"
userPoolClientId shouldBe "user-pool-client"
identityPoolId shouldBe "identity-pool"
Expand Down Expand Up @@ -294,7 +292,6 @@ class AmplifyOutputsDataTest {

// Auth
const val auth = "auth"
const val authFlowType = "authentication_flow_type"
const val userPoolId = "user_pool_id"
const val userPoolClientId = "user_pool_client_id"
const val identityPoolId = "identity_pool_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class AmazonPinpointBuilder : AmplifyOutputsData.Analytics.AmazonPinpoint {

class AuthBuilder : AmplifyOutputsData.Auth {
override var awsRegion: String = "us-east-1"
override var authenticationFlowType: AmplifyOutputsData.Auth.AuthenticationFlowType =
AmplifyOutputsData.Auth.AuthenticationFlowType.USER_SRP_AUTH
override var userPoolId: String = "user-pool-id"
override var userPoolClientId: String = "user-pool-client-id"
override var identityPoolId: String? = null
Expand Down