Make the application compile with a SDK with no support for Oidc.

This commit is contained in:
Benoit Marty 2023-05-30 15:50:25 +02:00 committed by Benoit Marty
parent 034e38ba5a
commit 71e0f6ee0e
5 changed files with 23 additions and 6 deletions

View file

@ -18,6 +18,6 @@ package io.element.android.features.login.impl.util
object LoginConstants { object LoginConstants {
const val DEFAULT_HOMESERVER_URL = "synapse-oidc.lab.element.dev" // "matrix.org" const val DEFAULT_HOMESERVER_URL = "matrix.org" // TODO Oidc "synapse-oidc.lab.element.dev"
const val SLIDING_SYNC_READ_MORE_URL = "https://github.com/matrix-org/sliding-sync/blob/main/docs/Landing.md" const val SLIDING_SYNC_READ_MORE_URL = "https://github.com/matrix-org/sliding-sync/blob/main/docs/Landing.md"
} }

View file

@ -27,11 +27,13 @@ fun Throwable.mapAuthenticationException(): Throwable {
is RustAuthenticationException.SessionMissing -> AuthenticationException.SessionMissing(this.message!!) is RustAuthenticationException.SessionMissing -> AuthenticationException.SessionMissing(this.message!!)
is RustAuthenticationException.SlidingSyncNotAvailable -> AuthenticationException.SlidingSyncNotAvailable(this.message!!) is RustAuthenticationException.SlidingSyncNotAvailable -> AuthenticationException.SlidingSyncNotAvailable(this.message!!)
/* TODO Oidc
is RustAuthenticationException.OidcException -> AuthenticationException.OidcError("OidcException", message!!) is RustAuthenticationException.OidcException -> AuthenticationException.OidcError("OidcException", message!!)
is RustAuthenticationException.OidcMetadataInvalid -> AuthenticationException.OidcError("OidcMetadataInvalid", message!!) is RustAuthenticationException.OidcMetadataInvalid -> AuthenticationException.OidcError("OidcMetadataInvalid", message!!)
is RustAuthenticationException.OidcMetadataMissing -> AuthenticationException.OidcError("OidcMetadataMissing", message!!) is RustAuthenticationException.OidcMetadataMissing -> AuthenticationException.OidcError("OidcMetadataMissing", message!!)
is RustAuthenticationException.OidcNotStarted -> AuthenticationException.OidcError("OidcNotStarted", message!!) is RustAuthenticationException.OidcNotStarted -> AuthenticationException.OidcError("OidcNotStarted", message!!)
is RustAuthenticationException.OidcNotSupported -> AuthenticationException.OidcError("OidcNotSupported", message!!) is RustAuthenticationException.OidcNotSupported -> AuthenticationException.OidcError("OidcNotSupported", message!!)
*/
else -> this else -> this
} }

View file

@ -23,6 +23,6 @@ fun HomeserverLoginDetails.map(): MatrixHomeServerDetails = use {
MatrixHomeServerDetails( MatrixHomeServerDetails(
url = url(), url = url(),
supportsPasswordLogin = supportsPasswordLogin(), supportsPasswordLogin = supportsPasswordLogin(),
supportsOidcLogin = supportsOidcLogin(), supportsOidcLogin = false // TODO Oidc supportsOidcLogin(),
) )
} }

View file

@ -17,8 +17,10 @@
package io.element.android.libraries.matrix.impl.auth package io.element.android.libraries.matrix.impl.auth
import io.element.android.libraries.matrix.api.auth.OidcConfig import io.element.android.libraries.matrix.api.auth.OidcConfig
import org.matrix.rustcomponents.sdk.OidcClientMetadata // TODO Oidc
// import org.matrix.rustcomponents.sdk.OidcClientMetadata
/*
val oidcClientMetadata: OidcClientMetadata = OidcClientMetadata( val oidcClientMetadata: OidcClientMetadata = OidcClientMetadata(
clientName = "Element", clientName = "Element",
redirectUri = OidcConfig.redirectUri, redirectUri = OidcConfig.redirectUri,
@ -26,4 +28,5 @@ val oidcClientMetadata: OidcClientMetadata = OidcClientMetadata(
tosUri = "https://element.io/user-terms-of-service", tosUri = "https://element.io/user-terms-of-service",
policyUri = "https://element.io/privacy" policyUri = "https://element.io/privacy"
) )
*/

View file

@ -36,7 +36,8 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.matrix.rustcomponents.sdk.Client import org.matrix.rustcomponents.sdk.Client
import org.matrix.rustcomponents.sdk.ClientBuilder import org.matrix.rustcomponents.sdk.ClientBuilder
import org.matrix.rustcomponents.sdk.OidcAuthenticationUrl // TODO Oidc
// import org.matrix.rustcomponents.sdk.OidcAuthenticationUrl
import org.matrix.rustcomponents.sdk.Session import org.matrix.rustcomponents.sdk.Session
import org.matrix.rustcomponents.sdk.use import org.matrix.rustcomponents.sdk.use
import java.io.File import java.io.File
@ -55,7 +56,8 @@ class RustMatrixAuthenticationService @Inject constructor(
private val authService: RustAuthenticationService = RustAuthenticationService( private val authService: RustAuthenticationService = RustAuthenticationService(
basePath = baseDirectory.absolutePath, basePath = baseDirectory.absolutePath,
passphrase = null, passphrase = null,
oidcClientMetadata = oidcClientMetadata, // TODO Oidc
// oidcClientMetadata = oidcClientMetadata,
customSlidingSyncProxy = null customSlidingSyncProxy = null
) )
private var currentHomeserver = MutableStateFlow<MatrixHomeServerDetails?>(null) private var currentHomeserver = MutableStateFlow<MatrixHomeServerDetails?>(null)
@ -114,9 +116,12 @@ class RustMatrixAuthenticationService @Inject constructor(
} }
} }
private var pendingUrlForOidcLogin: OidcAuthenticationUrl? = null // TODO Oidc
// private var pendingUrlForOidcLogin: OidcAuthenticationUrl? = null
override suspend fun getOidcUrl(): Result<OidcDetails> { override suspend fun getOidcUrl(): Result<OidcDetails> {
TODO("Oidc")
/*
return withContext(coroutineDispatchers.io) { return withContext(coroutineDispatchers.io) {
runCatching { runCatching {
val urlForOidcLogin = authService.urlForOidcLogin() val urlForOidcLogin = authService.urlForOidcLogin()
@ -127,9 +132,12 @@ class RustMatrixAuthenticationService @Inject constructor(
failure.mapAuthenticationException() failure.mapAuthenticationException()
} }
} }
*/
} }
override suspend fun cancelOidcLogin(): Result<Unit> { override suspend fun cancelOidcLogin(): Result<Unit> {
TODO("Oidc")
/*
return withContext(coroutineDispatchers.io) { return withContext(coroutineDispatchers.io) {
runCatching { runCatching {
pendingUrlForOidcLogin?.close() pendingUrlForOidcLogin?.close()
@ -138,12 +146,15 @@ class RustMatrixAuthenticationService @Inject constructor(
failure.mapAuthenticationException() failure.mapAuthenticationException()
} }
} }
*/
} }
/** /**
* callbackUrl should be the uriRedirect from OidcClientMetadata (with all the parameters). * callbackUrl should be the uriRedirect from OidcClientMetadata (with all the parameters).
*/ */
override suspend fun loginWithOidc(callbackUrl: String): Result<SessionId> { override suspend fun loginWithOidc(callbackUrl: String): Result<SessionId> {
TODO("Oidc")
/*
return withContext(coroutineDispatchers.io) { return withContext(coroutineDispatchers.io) {
runCatching { runCatching {
val urlForOidcLogin = pendingUrlForOidcLogin ?: error("You need to call `getOidcUrl()` first") val urlForOidcLogin = pendingUrlForOidcLogin ?: error("You need to call `getOidcUrl()` first")
@ -156,6 +167,7 @@ class RustMatrixAuthenticationService @Inject constructor(
failure.mapAuthenticationException() failure.mapAuthenticationException()
} }
} }
*/
} }
private fun createMatrixClient(client: Client): MatrixClient { private fun createMatrixClient(client: Client): MatrixClient {