-
Notifications
You must be signed in to change notification settings - Fork 6
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: e2ei endpoint is called even when the feature is disabled #2508
Merged
MohamadJaara
merged 4 commits into
release/candidate
from
fix/e2ei-url-is-mapped-to-empty-string-when-missing
Feb 19, 2024
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import com.wire.kalium.cryptography.AcmeDirectory | |
import com.wire.kalium.cryptography.NewAcmeAuthz | ||
import com.wire.kalium.cryptography.NewAcmeOrder | ||
import com.wire.kalium.logic.CoreFailure | ||
import com.wire.kalium.logic.E2EIFailure | ||
import com.wire.kalium.logic.configuration.UserConfigRepository | ||
import com.wire.kalium.logic.data.client.E2EIClientProvider | ||
import com.wire.kalium.logic.data.client.MLSClientProvider | ||
|
@@ -35,6 +36,7 @@ import com.wire.kalium.logic.functional.Either | |
import com.wire.kalium.logic.functional.flatMap | ||
import com.wire.kalium.logic.functional.fold | ||
import com.wire.kalium.logic.functional.getOrFail | ||
import com.wire.kalium.logic.functional.left | ||
import com.wire.kalium.logic.functional.map | ||
import com.wire.kalium.logic.kaliumLogger | ||
import com.wire.kalium.logic.wrapApiRequest | ||
|
@@ -91,6 +93,7 @@ interface E2EIRepository { | |
suspend fun fetchFederationCertificates(): Either<CoreFailure, Unit> | ||
suspend fun getCurrentClientCrlUrl(): Either<CoreFailure, String> | ||
suspend fun getClientDomainCRL(url: String): Either<CoreFailure, ByteArray> | ||
fun discoveryUrl(): Either<CoreFailure, String> | ||
} | ||
|
||
@Suppress("LongParameterList") | ||
|
@@ -116,9 +119,9 @@ class E2EIRepositoryImpl( | |
}) | ||
} | ||
|
||
override suspend fun fetchAndSetTrustAnchors(): Either<CoreFailure, Unit> = userConfigRepository.getE2EISettings().flatMap { | ||
override suspend fun fetchAndSetTrustAnchors(): Either<CoreFailure, Unit> = discoveryUrl().flatMap { | ||
wrapApiRequest { | ||
acmeApi.getTrustAnchors(Url(it.discoverUrl).protocolWithAuthority) | ||
acmeApi.getTrustAnchors(Url(it).protocolWithAuthority) | ||
}.flatMap { trustAnchors -> | ||
mlsClientProvider.getMLSClient().flatMap { mlsClient -> | ||
wrapE2EIRequest { | ||
|
@@ -128,9 +131,9 @@ class E2EIRepositoryImpl( | |
} | ||
} | ||
|
||
override suspend fun loadACMEDirectories(): Either<CoreFailure, AcmeDirectory> = userConfigRepository.getE2EISettings().flatMap { | ||
override suspend fun loadACMEDirectories(): Either<CoreFailure, AcmeDirectory> = discoveryUrl().flatMap { | ||
wrapApiRequest { | ||
acmeApi.getACMEDirectories(it.discoverUrl) | ||
acmeApi.getACMEDirectories(it) | ||
}.flatMap { directories -> | ||
e2EIClientProvider.getE2EIClient().flatMap { e2eiClient -> | ||
wrapE2EIRequest { | ||
|
@@ -301,29 +304,37 @@ class E2EIRepositoryImpl( | |
Either.Right(e2EIClient.getOAuthRefreshToken()) | ||
} | ||
|
||
override suspend fun fetchFederationCertificates(): Either<CoreFailure, Unit> = userConfigRepository.getE2EISettings().flatMap { | ||
wrapApiRequest { | ||
acmeApi.getACMEFederation(Url(it.discoverUrl).protocolWithAuthority) | ||
}.flatMap { data -> | ||
mlsClientProvider.getMLSClient().flatMap { mlsClient -> | ||
wrapMLSRequest { | ||
mlsClient.registerIntermediateCa(data) | ||
override suspend fun fetchFederationCertificates(): Either<CoreFailure, Unit> = discoveryUrl() | ||
.flatMap { | ||
wrapApiRequest { | ||
acmeApi.getACMEFederation(Url(it).protocolWithAuthority) | ||
}.flatMap { data -> | ||
mlsClientProvider.getMLSClient().flatMap { mlsClient -> | ||
wrapMLSRequest { | ||
mlsClient.registerIntermediateCa(data) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun discoveryUrl(): Either<CoreFailure, String> = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the idea of this function is to have a central place where the errors with e2ei url are caught |
||
userConfigRepository.getE2EISettings().flatMap { settings -> | ||
when { | ||
!settings.isRequired -> E2EIFailure.Disabled.left() | ||
settings.discoverUrl == null -> E2EIFailure.MissingDiscoveryUrl.left() | ||
else -> Either.Right(settings.discoverUrl) | ||
} | ||
} | ||
|
||
override suspend fun nukeE2EIClient() { | ||
e2EIClientProvider.nuke() | ||
} | ||
|
||
override suspend fun getCurrentClientCrlUrl(): Either<CoreFailure, String> = | ||
userConfigRepository.getE2EISettings().map { | ||
(Url(it.discoverUrl).protocolWithAuthority) | ||
} | ||
discoveryUrl().map { Url(it).protocolWithAuthority } | ||
|
||
override suspend fun getClientDomainCRL(url: String): Either<CoreFailure, ByteArray> = | ||
wrapApiRequest { | ||
acmeApi.getClientDomainCRL(url) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,7 +203,7 @@ data class TeamSettingsSelfDeletionStatusEntity( | |
@Serializable | ||
data class E2EISettingsEntity( | ||
@SerialName("status") val status: Boolean, | ||
@SerialName("discoverUrl") val discoverUrl: String, | ||
@SerialName("discoverUrl") val discoverUrl: String?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. according to swagger this URL can be null |
||
@SerialName("gracePeriodEndMs") val gracePeriodEndMs: Long?, | ||
) | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the url can be null even when the feature is enabled 😢