Этап 0 п.3: безопасность-минимум (trust-all off в release, шифрование пароля, allowBackup, ревокация)

1. trust-all TLS отключён в release: гейт if(!BuildConfig.DEBUG) в UnsafeSsl +
   OfficeWebViewClient + TalkCallActivity; чекбокс скрыт в release. buildConfig
   включён в core:network и feature:talk.
2. allowBackup=false (tools:replace поверх vendor true).
3. app password шифруется в покое AndroidKeystore AES-256-GCM (KeystoreCrypto),
   AuthStore мигрирует legacy-plaintext при первом load. Биометрия — отдельная
   задача (ломает фоновые push/звонки, нужен кэш в памяти).
4. Ревокация app password при logout (AppPasswordRevoker, DELETE core/apppassword,
   best-effort).

Проверено: assembleRelease 53 МБ, подпись v2+v3, allowBackup=false в манифесте OK.
This commit is contained in:
b-dev-mobile
2026-07-07 19:51:23 +00:00
parent c259936e82
commit 51fd1bf936
12 changed files with 167 additions and 20 deletions
+2 -2
View File
@@ -22,13 +22,13 @@
<application
android:name=".F7MobileApp"
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar"
tools:replace="android:label,android:theme,android:icon,android:roundIcon">
tools:replace="android:label,android:theme,android:icon,android:roundIcon,android:allowBackup">
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="f7cloud_messages_v2" />
@@ -88,7 +88,8 @@ internal class OfficeWebViewClient(
handler: SslErrorHandler?,
error: SslError?,
) {
if (launch.trustAllCerts) {
// trust-all TLS в WebView — только debug (см. UnsafeSsl); в release всегда штатная проверка.
if (launch.trustAllCerts && BuildConfig.DEBUG) {
handler?.proceed()
} else {
super.onReceivedSslError(view, handler, error)
@@ -71,6 +71,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import ru.forbion.f7cloud.mobile.BuildConfig
import ru.forbion.f7cloud.core.auth.AppLockStore
import ru.forbion.f7cloud.core.auth.AppPasswordRevoker
import ru.forbion.f7cloud.core.auth.AuthSession
import ru.forbion.f7cloud.core.auth.AuthStore
import ru.forbion.f7cloud.core.auth.AuthVerifier
@@ -172,7 +173,12 @@ fun AppScaffold(
context.applicationContext.getSharedPreferences("f7_permissions", android.content.Context.MODE_PRIVATE)
}
val logoutScope = rememberCoroutineScope()
val forceLogout = {
// Best-effort ревокация app password на сервере ДО очистки локальной сессии.
session?.let { current ->
logoutScope.launch { AppPasswordRevoker.revoke(current) }
}
OfficeWarmup.clear()
OfficeWebViewPool.dispose()
authStore.clear()
@@ -873,19 +879,23 @@ private fun LoginScreen(onLogin: (AuthSession) -> Unit) {
submitLogin()
},
)
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
Checkbox(
checked = trustAllCerts,
onCheckedChange = { trustAllCerts = it },
)
Text(
text = "Доверять сертификату (dev)",
style = MaterialTheme.typography.bodySmall,
color = F7Colors.TextSecondary,
)
// Чекбокс trust-all показываем только в debug-сборках: в release он
// всё равно игнорируется на уровне сети/WebView (см. UnsafeSsl).
if (BuildConfig.DEBUG) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
Checkbox(
checked = trustAllCerts,
onCheckedChange = { trustAllCerts = it },
)
Text(
text = "Доверять сертификату (dev)",
style = MaterialTheme.typography.bodySmall,
color = F7Colors.TextSecondary,
)
}
}
Spacer(Modifier.height(8.dp))
F7PrimaryButton(