Skip to content

Commit

Permalink
feat(e2ei): set claims in OAuth flow (#2623)
Browse files Browse the repository at this point in the history
  • Loading branch information
mchenani authored Jan 25, 2024
1 parent 7c7bbef commit 936df80
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GetE2EICertificateUseCase @Inject constructor(
}, {
if (it is E2EIEnrollmentResult.Initialized) {
initialEnrollmentResult = it
OAuthUseCase(context, it.target, it.oAuthState).launch(
OAuthUseCase(context, it.target, it.oAuthClaims, it.oAuthState).launch(
context.getActivity()!!.activityResultRegistry,
::oAuthResultHandler
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.activity.result.ActivityResultRegistry
import androidx.activity.result.contract.ActivityResultContracts
import com.wire.android.appLogger
import com.wire.android.util.deeplink.DeepLinkProcessor
import kotlinx.serialization.json.JsonObject
import net.openid.appauth.AppAuthConfiguration
import net.openid.appauth.AuthState
import net.openid.appauth.AuthorizationException
Expand All @@ -41,6 +42,7 @@ import net.openid.appauth.ResponseTypeValues
import net.openid.appauth.browser.BrowserAllowList
import net.openid.appauth.browser.VersionedBrowserMatcher
import net.openid.appauth.connectivity.ConnectionBuilder
import org.json.JSONObject
import java.net.HttpURLConnection
import java.net.URL
import java.security.MessageDigest
Expand All @@ -52,7 +54,7 @@ import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager

class OAuthUseCase(context: Context, private val authUrl: String, oAuthState: String?) {
class OAuthUseCase(context: Context, private val authUrl: String, private val claims: JsonObject, oAuthState: String?) {
private var authState: AuthState = oAuthState?.let {
AuthState.jsonDeserialize(it)
} ?: AuthState()
Expand Down Expand Up @@ -177,7 +179,8 @@ class OAuthUseCase(context: Context, private val authUrl: String, oAuthState: St
AuthorizationRequest.Scope.EMAIL,
AuthorizationRequest.Scope.PROFILE,
AuthorizationRequest.Scope.OFFLINE_ACCESS
).build()
).setClaims(JSONObject(claims.toString()))
.build()

private fun AuthorizationRequest.Builder.setCodeVerifier(): AuthorizationRequest.Builder {
val codeVerifier = getCodeVerifier()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.verify
import kotlinx.coroutines.test.runTest
import org.amshove.kluent.internal.assertEquals
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -77,7 +76,7 @@ class SearchUserViewModelTest {
)
}

verify(exactly = 1) {
coVerify(exactly = 1) {
arrangement.federatedSearchParser(any())
}
}
Expand Down Expand Up @@ -114,7 +113,7 @@ class SearchUserViewModelTest {
)
}

verify(exactly = 1) {
coVerify(exactly = 1) {
arrangement.federatedSearchParser(any())
}
}
Expand Down Expand Up @@ -170,7 +169,7 @@ class SearchUserViewModelTest {
)
}

verify(exactly = 1) {
coVerify(exactly = 1) {
arrangement.federatedSearchParser(any())
}

Expand Down
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 86 files
+13 βˆ’2 .github/workflows/cherry-pick-rc-to-develop.yml
+3 βˆ’2 cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/E2EIClientImpl.kt
+3 βˆ’2 cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/E2EIClient.kt
+1 βˆ’1 gradle/libs.versions.toml
+21 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/UserConfigRepository.kt
+1 βˆ’1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepository.kt
+12 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/e2ei/E2EIRepository.kt
+1 βˆ’1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/id/FederatedIdMapperImpl.kt
+26 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageRepository.kt
+12 βˆ’1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/ProtoContentMapper.kt
+2 βˆ’2 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/session/SessionRepository.kt
+25 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt
+3 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/ConversationScope.kt
+5 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/NotifyConversationIsOpenUseCase.kt
+56 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/CheckRevocationListUseCase.kt
+24 βˆ’1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/EnrollE2EIUseCase.kt
+47 βˆ’0 ...nMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/ObserveCertificateRevocationForSelfClientUseCase.kt
+1 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/MLSMessageCreator.kt
+15 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/MessageScope.kt
+79 βˆ’0 ...onMain/kotlin/com/wire/kalium/logic/feature/message/composite/SendButtonActionConfirmationMessageUseCase.kt
+34 βˆ’0 ...c/commonMain/kotlin/com/wire/kalium/logic/feature/message/ephemeral/DeleteEphemeralMessageEndDateUseCase.kt
+24 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/ephemeral/EphemeralMessageDeletionHandler.kt
+23 βˆ’9 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/search/FederatedSearchParser.kt
+13 βˆ’2 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/user/UserScope.kt
+35 βˆ’0 ...mmonMain/kotlin/com/wire/kalium/logic/feature/user/e2ei/MarkNotifyForRevokedCertificateAsNotifiedUseCase.kt
+47 βˆ’0 ...ommonMain/kotlin/com/wire/kalium/logic/feature/user/e2ei/ObserveShouldNotifyForRevokedCertificateUseCase.kt
+3 βˆ’2 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/asset/AssetRepositoryTest.kt
+2 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/e2ei/E2EIRepositoryTest.kt
+4 βˆ’4 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/id/FederatedIdMapperTest.kt
+24 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/NotifyConversationIsOpenUseCaseTest.kt
+25 βˆ’2 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/EnrollE2EICertificateUseCaseTest.kt
+266 βˆ’0 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/CheckRevocationListUseCaseTest.kt
+100 βˆ’0 ...ommonTest/kotlin/com/wire/kalium/logic/feature/message/composite/SendButtonActionConfirmationMessageTest.kt
+61 βˆ’0 ...st/kotlin/com/wire/kalium/logic/feature/message/ephemeral/DeleteEphemeralMessagesAfterEndDateUseCaseTest.kt
+34 βˆ’0 ...rc/commonTest/kotlin/com/wire/kalium/logic/feature/message/ephemeral/EphemeralMessageDeletionHandlerTest.kt
+5 βˆ’4 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/search/FederatedSearchParserTest.kt
+63 βˆ’0 ...Test/kotlin/com/wire/kalium/logic/feature/user/e2ei/MarkNotifyForRevokedCertificateAsNotifiedUseCaseTest.kt
+81 βˆ’0 ...nTest/kotlin/com/wire/kalium/logic/feature/user/e2ei/ObserveShouldNotifyForRevokedCertificateUseCaseTest.kt
+1 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/SessionRepositoryArrangement.kt
+2 βˆ’2 network/src/commonMain/kotlin/com/wire/kalium/network/BackendMetaDataUtil.kt
+6 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/base/unbound/acme/ACMEApi.kt
+1 βˆ’1 network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AccessTokenApiV5.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AccessTokenApiV6.kt
+28 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AssetApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/CallApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/ClientApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/ConnectionApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/ConversationApiV6.kt
+25 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/E2EIApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/FeatureConfigApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/KeyPackageApiV6.kt
+28 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/LogoutApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSMessageApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSPublicKeyApiV6.kt
+28 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MessageApiV6.kt
+30 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/NotificationApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/PreKeyApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/PropertiesApiV6.kt
+28 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/SelfApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/TeamsApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/UserDetailsApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/UserSearchApiV6.kt
+134 βˆ’0 ...ain/kotlin/com/wire/kalium/network/api/v6/authenticated/networkContainer/AuthenticatedNetworkContainerV6.kt
+25 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/DomainLookupApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/LoginApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/RegisterApiV6.kt
+26 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/SSOLoginApiV6.kt
+25 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/VerificationCodeApiV6.kt
+66 βˆ’0 ...kotlin/com/wire/kalium/network/api/v6/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV6.kt
+11 βˆ’1 network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt
+9 βˆ’0 network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt
+1 βˆ’0 persistence/src/commonMain/db_user/com/wire/kalium/persistence/MessageDetailsView.sq
+14 βˆ’0 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Messages.sq
+167 βˆ’0 persistence/src/commonMain/db_user/migrations/73.sqm
+4 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageDAO.kt
+16 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageDAOImpl.kt
+1 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageMapper.kt
+47 βˆ’5 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/unread/UserConfigDAO.kt
+5 βˆ’3 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/AccountsDAO.kt
+2 βˆ’1 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/db/TableMapper.kt
+47 βˆ’0 persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/message/MessageDAOTest.kt
+2 βˆ’0 persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/message/MessageMapperTest.kt
+37 βˆ’2 testservice/src/main/kotlin/com/wire/kalium/testservice/api/v1/ConversationResources.kt
+65 βˆ’0 testservice/src/main/kotlin/com/wire/kalium/testservice/managed/ConversationRepository.kt
+26 βˆ’0 testservice/src/main/kotlin/com/wire/kalium/testservice/models/SendButtonActionConfirmationRequest.kt
+25 βˆ’0 testservice/src/main/kotlin/com/wire/kalium/testservice/models/SendButtonActionRequest.kt

0 comments on commit 936df80

Please sign in to comment.