From f8d6423f0dc35608f540ba18623409b88456af24 Mon Sep 17 00:00:00 2001 From: Fabian Devel Date: Mon, 16 Dec 2024 09:37:50 +0100 Subject: [PATCH] feat(AppIntegrity): Force debug build to check app integrity on preprod --- Core2/AppIntegrity/build.gradle.kts | 11 ++++++++++- .../core2/appintegrity/AppIntegrityRepository.kt | 2 +- .../core2/appintegrity/AppIntegrityRoutes.kt | 8 +++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Core2/AppIntegrity/build.gradle.kts b/Core2/AppIntegrity/build.gradle.kts index 1b7cce0ab9..d69c63c095 100644 --- a/Core2/AppIntegrity/build.gradle.kts +++ b/Core2/AppIntegrity/build.gradle.kts @@ -23,9 +23,18 @@ android { release { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + buildConfigField("String", "APP_INTEGRITY_BASE_URL", "\"https://api.infomaniak.com\"") + } + + debug { + buildConfigField("String", "APP_INTEGRITY_BASE_URL", "\"https://api.preprod.dev.infomaniak.ch\"") } } + buildFeatures { + buildConfig = true + } + compileOptions { sourceCompatibility = sharedJavaVersion targetCompatibility = sharedJavaVersion @@ -39,7 +48,7 @@ android { dependencies { implementation(project(":Core2:Sentry")) - + implementation(core2.integrity) implementation(core2.ktor.client.core) implementation(core2.ktor.client.content.negociation) diff --git a/Core2/AppIntegrity/src/main/java/com/infomaniak/core2/appintegrity/AppIntegrityRepository.kt b/Core2/AppIntegrity/src/main/java/com/infomaniak/core2/appintegrity/AppIntegrityRepository.kt index 4172ee416a..5790132a38 100644 --- a/Core2/AppIntegrity/src/main/java/com/infomaniak/core2/appintegrity/AppIntegrityRepository.kt +++ b/Core2/AppIntegrity/src/main/java/com/infomaniak/core2/appintegrity/AppIntegrityRepository.kt @@ -53,7 +53,7 @@ internal class AppIntegrityRepository { "package_name" to packageName, "target_url" to targetUrl, "challenge_id" to challengeId, - "force_integrity_test" to "true", + "force_integrity_test" to "false", ) return post>(url = Url(AppIntegrityRoutes.requestApiIntegrityCheck), data = body) diff --git a/Core2/AppIntegrity/src/main/java/com/infomaniak/core2/appintegrity/AppIntegrityRoutes.kt b/Core2/AppIntegrity/src/main/java/com/infomaniak/core2/appintegrity/AppIntegrityRoutes.kt index 0f1a04b990..4de5af3dae 100644 --- a/Core2/AppIntegrity/src/main/java/com/infomaniak/core2/appintegrity/AppIntegrityRoutes.kt +++ b/Core2/AppIntegrity/src/main/java/com/infomaniak/core2/appintegrity/AppIntegrityRoutes.kt @@ -19,11 +19,9 @@ package com.infomaniak.core2.appintegrity object AppIntegrityRoutes { - private const val PROD_URL = "https://https://api.infomaniak.com" - private const val PREPROD_BASE_URL = "https://api.preprod.dev.infomaniak.ch" - private const val BASE_URL_V1 = "$PREPROD_BASE_URL/1/attest" + private val BASE_URL_V1 = "${BuildConfig.APP_INTEGRITY_BASE_URL}/1/attest" - internal const val requestChallenge = "$BASE_URL_V1/challenge" - internal const val requestApiIntegrityCheck = "$BASE_URL_V1/integrity" + internal val requestChallenge = "$BASE_URL_V1/challenge" + internal val requestApiIntegrityCheck = "$BASE_URL_V1/integrity" const val demo = "https://api-core.devd471.dev.infomaniak.ch/1/attest/demo" }