Skip to content

Commit

Permalink
Merge pull request #65 from kirillzh/add-CustomAuth-flow
Browse files Browse the repository at this point in the history
Add customAuth API (#61)
  • Loading branch information
benjohnde authored Jun 24, 2023
2 parents 851a4eb + 988070a commit 945ef8c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ open class IdentityProviderClient(region: String, clientId: String, engine: Http
)
)

override suspend fun customAuth(
username: String,
password: String,
): Result<SignInResponse> = request(
Request.SignIn,
SignIn(
AuthFlow = Authentication.CustomAuth.flow,
ClientId = configuration.clientId,
AuthParameters = SignIn.Parameters(username, password)
)
)

override suspend fun resendConfirmationCode(
username: String
): Result<ResendConfirmationCodeResponse> = request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ internal object Header {

internal enum class Authentication(val flow: String) {
RefreshTokenAuth("REFRESH_TOKEN_AUTH"),
UserPasswordAuth("USER_PASSWORD_AUTH")
UserPasswordAuth("USER_PASSWORD_AUTH"),
CustomAuth("CUSTOM_AUTH"),
}

internal enum class Request(val value: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ interface IdentityProvider {
*/
suspend fun confirmSignUp(username: String, confirmationCode: String): Result<Unit>

/**
* Signs in the user with the given parameters using custom authentication flow.
* @param username The username
* @param password The password
* @return Result object containing SignInResponse on success or an error on failure
*/
suspend fun customAuth(username: String, password: String): Result<SignInResponse>

/**
* Resends the confirmation (for confirmation of registration) to a specific user in the user pool.
* @param username The username
Expand Down

0 comments on commit 945ef8c

Please sign in to comment.