Skip to content

Commit

Permalink
Merge pull request #7190 from thundernest/fix_oauth2_for_yahoo_and_ao…
Browse files Browse the repository at this point in the history
…l_accounts

Fix OAuth 2.0 for Yahoo and AOL
  • Loading branch information
wmontwe authored Sep 22, 2023
2 parents 8d8450b + 4ec59a8 commit 2c8e0b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import net.openid.appauth.AuthorizationRequest
import net.openid.appauth.AuthorizationResponse
import net.openid.appauth.AuthorizationService
import net.openid.appauth.AuthorizationServiceConfiguration
import net.openid.appauth.CodeVerifierUtil
import net.openid.appauth.ResponseTypeValues
import timber.log.Timber

Expand Down Expand Up @@ -80,9 +81,11 @@ class AuthorizationRepository(
configuration.redirectUri.toUri(),
)

val codeVerifier = CodeVerifierUtil.generateRandomCodeVerifier()

val authRequest = authRequestBuilder
.setScope(configuration.scopes.joinToString(" "))
.setCodeVerifier(null)
.setCodeVerifier(codeVerifier)
.setLoginHint(emailAddress)
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import app.k9mail.feature.account.oauth.domain.entity.AuthorizationResult
import assertk.all
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isNotEmpty
import assertk.assertions.isNotNull
import assertk.assertions.isNull
import assertk.assertions.prop
Expand Down Expand Up @@ -72,8 +73,10 @@ class AuthorizationRepositoryTest {
prop(AuthorizationRequest::responseType).isEqualTo(ResponseTypeValues.CODE)
prop(AuthorizationRequest::redirectUri).isEqualTo(oAuthConfiguration.redirectUri.toUri())
prop(AuthorizationRequest::scope).isEqualTo("scope scope2")
prop(AuthorizationRequest::codeVerifier).isNull()
prop(AuthorizationRequest::loginHint).isEqualTo(emailAddress)
prop(AuthorizationRequest::codeVerifier).isNotNull()
prop(AuthorizationRequest::codeVerifierChallengeMethod).isEqualTo("S256")
prop(AuthorizationRequest::codeVerifierChallenge).isNotNull().isNotEmpty()
}
}

Expand Down

0 comments on commit 2c8e0b8

Please sign in to comment.