-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Data transfer support #825
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
Merged
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
cb1a23c
chore: Move DerivedTokenGenerator to the Auth module
LouisCAD 6bf4b7b
feat: Introduce the RestoreFromBackupManager interface
LouisCAD a33e9dc
chore: Add suspending allUsers() in UserDao
LouisCAD 32eccb9
feat: Add WIP RestoreFromBackupManagerImpl
LouisCAD ac89757
chore: Forward issues from DerivedTokenGenerator in RestoreFromBackup…
LouisCAD 1ef83db
chore: Store user token to device association in the db instead of a …
LouisCAD 8f773d4
chore: Move ensureRestorationIsHandled from impl to the sealed class
LouisCAD 811938a
chore: Add `shouldShowRestorationScreen` helper in RestoreFromBackupM…
LouisCAD b7d365c
feat: Auto retry post-restoration token derivation if appropriate
LouisCAD 7d7e175
fix: Use a getter to get the up-to-date userDataCleanableList
LouisCAD 379fb71
feat: Remove relevant users when the user gives up backup restoration
LouisCAD 578056c
docs: Update CrossAppLogin README.md
LouisCAD 30e3236
fix: Fix crashes and race condition
LouisCAD 9cb8e27
feat: Add barebones RestoringFromBackupFailedScreen
LouisCAD d2977e9
feat: Move landscape UI of backup restoration failed to the end
LouisCAD fe6832e
fix: Fix AccountUtils tests
LouisCAD f476bba
fix: Ensure attestation tokens cannot be reused
LouisCAD 7aff9d8
feat: Add strings
Elouan1411 a288a06
fix: Update UI
Elouan1411 5153c98
chore: Extract nested when
LouisCAD d981a32
fix: Don't auto-retry if we received http 401
LouisCAD 4aa1948
chore: Add braces to if branch
LouisCAD 8f4b1db
chore: Add fast-path for not set up app
LouisCAD fcac944
feat: Support the Authenticator app
LouisCAD 102cbca
chore: Fix compilation by adding a default parameter value
LouisCAD 678b700
chore: Ensure we don't auto-retry http 400 requests
LouisCAD 8203de8
docs: Add KDoc to explain why a parameter is needed
LouisCAD 6784b85
refactor: Extract 2 functions
LouisCAD 46c9e4d
chore: Use our Margin constants
LouisCAD efabd6e
chore: Rename composable to be more accurate
LouisCAD b8c0830
feat: Add WIP RestoreFromBackupManagerImpl
LouisCAD b31717b
chore: Store user token to device association in the db instead of a …
LouisCAD fc18ac1
test: Add RestoreFromBackupManagerImpl tests for data transfer support
Copilot adeab26
test: Allow DerivedTokenGenerator to be subclassed from tests
LouisCAD 1ea07df
test: Add timeout for tests so they fail sooner
LouisCAD 5cc7d3c
test: Use kotest assertions for better readability
LouisCAD 21c16f8
test: Move helpers at the end of the file
LouisCAD e9dea3b
test: Use new testUserDb helper for conciseness
LouisCAD 75e500a
test: Replace reference comment by constant
LouisCAD da5b142
test: Add extra test helper for more conciseness
LouisCAD 85ac25d
test: Add custom test scope for more conciseness
LouisCAD 1db50ce
test: Add extra assertions in RestoreFromBackupManagerImplTest
LouisCAD 8086fe8
test: Update function names to be more readable
LouisCAD 80eca9e
chore(CrossAppLogin): Avoid disabling cross app login in more cases
LouisCAD 2a3cb1e
feat: Add BackupAgent helpers
LouisCAD 47bd369
feat: Update TransportAwareFileBackupHandler for more granularity
LouisCAD 8327fad
refactor: Extract BackupPolicy to separate file
LouisCAD b960fc8
chore: Remove BackupAgentBase and TransportAwareFileBackupHandler
LouisCAD 692f3a3
feat: Introduce FullBackupAgent
LouisCAD 0380a29
feat: Add FullBackup to restore file not included in XML rules
LouisCAD f179c79
refactor: Rename .java to .kt
LouisCAD 9f6c202
fix: Fix compilation by converting FullBackup.java to Kotlin
LouisCAD a720335
chore: Replace unneeded userDb property with constructor property
LouisCAD 7b3c22d
chore: Move companion object at the end of the file
LouisCAD 10034de
chore: Make BaseAccountUtilsTest companion object protected
LouisCAD 07d3b8f
docs: Add KDoc and remove unneeded nullability
LouisCAD 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 hidden or 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
213 changes: 213 additions & 0 deletions
213
Auth/schemas/com.infomaniak.core.auth.room.UserDatabase/10.json
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| { | ||
| "formatVersion": 1, | ||
| "database": { | ||
| "version": 10, | ||
| "identityHash": "6d4be66bdbd5459afb46f129e14738f7", | ||
| "entities": [ | ||
| { | ||
| "tableName": "User", | ||
| "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `displayName` TEXT, `firstname` TEXT NOT NULL, `lastname` TEXT NOT NULL, `email` TEXT NOT NULL, `avatar` TEXT, `phones` TEXT, `card` TEXT, `login` TEXT NOT NULL, `isStaff` INTEGER NOT NULL DEFAULT false, `organizations` TEXT NOT NULL, `preferences_security_score` INTEGER DEFAULT 0, `preferences_security_dateLastChangedPassword` INTEGER DEFAULT 0, `preferences_organizationPreference_currentOrganizationId` INTEGER NOT NULL DEFAULT 0, `accessToken` TEXT NOT NULL, `refreshToken` TEXT, `tokenType` TEXT NOT NULL, `expiresIn` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `scope` TEXT, `expiresAt` INTEGER, `isTemporary` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))", | ||
| "fields": [ | ||
| { | ||
| "fieldPath": "id", | ||
| "columnName": "id", | ||
| "affinity": "INTEGER", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "displayName", | ||
| "columnName": "displayName", | ||
| "affinity": "TEXT" | ||
| }, | ||
| { | ||
| "fieldPath": "firstname", | ||
| "columnName": "firstname", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "lastname", | ||
| "columnName": "lastname", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "email", | ||
| "columnName": "email", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "avatar", | ||
| "columnName": "avatar", | ||
| "affinity": "TEXT" | ||
| }, | ||
| { | ||
| "fieldPath": "phones", | ||
| "columnName": "phones", | ||
| "affinity": "TEXT" | ||
| }, | ||
| { | ||
| "fieldPath": "card", | ||
| "columnName": "card", | ||
| "affinity": "TEXT" | ||
| }, | ||
| { | ||
| "fieldPath": "login", | ||
| "columnName": "login", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "isStaff", | ||
| "columnName": "isStaff", | ||
| "affinity": "INTEGER", | ||
| "notNull": true, | ||
| "defaultValue": "false" | ||
| }, | ||
| { | ||
| "fieldPath": "organizations", | ||
| "columnName": "organizations", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "preferences.security.score", | ||
| "columnName": "preferences_security_score", | ||
| "affinity": "INTEGER", | ||
| "defaultValue": "0" | ||
| }, | ||
| { | ||
| "fieldPath": "preferences.security.dateLastChangedPassword", | ||
| "columnName": "preferences_security_dateLastChangedPassword", | ||
| "affinity": "INTEGER", | ||
| "defaultValue": "0" | ||
| }, | ||
| { | ||
| "fieldPath": "preferences.organizationPreference.currentOrganizationId", | ||
| "columnName": "preferences_organizationPreference_currentOrganizationId", | ||
| "affinity": "INTEGER", | ||
| "notNull": true, | ||
| "defaultValue": "0" | ||
| }, | ||
| { | ||
| "fieldPath": "apiToken.accessToken", | ||
| "columnName": "accessToken", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "apiToken.refreshToken", | ||
| "columnName": "refreshToken", | ||
| "affinity": "TEXT" | ||
| }, | ||
| { | ||
| "fieldPath": "apiToken.tokenType", | ||
| "columnName": "tokenType", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "apiToken.expiresIn", | ||
| "columnName": "expiresIn", | ||
| "affinity": "INTEGER", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "apiToken.userId", | ||
| "columnName": "userId", | ||
| "affinity": "INTEGER", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "apiToken.scope", | ||
| "columnName": "scope", | ||
| "affinity": "TEXT" | ||
| }, | ||
| { | ||
| "fieldPath": "apiToken.expiresAt", | ||
| "columnName": "expiresAt", | ||
| "affinity": "INTEGER" | ||
| }, | ||
| { | ||
| "fieldPath": "apiToken.isTemporary", | ||
| "columnName": "isTemporary", | ||
| "affinity": "INTEGER", | ||
| "notNull": true, | ||
| "defaultValue": "0" | ||
| } | ||
| ], | ||
| "primaryKey": { | ||
| "autoGenerate": false, | ||
| "columnNames": [ | ||
| "id" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "tableName": "CurrentUserId", | ||
| "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER, `uniqueKey` TEXT NOT NULL, PRIMARY KEY(`uniqueKey`))", | ||
| "fields": [ | ||
| { | ||
| "fieldPath": "id", | ||
| "columnName": "id", | ||
| "affinity": "INTEGER" | ||
| }, | ||
| { | ||
| "fieldPath": "uniqueKey", | ||
| "columnName": "uniqueKey", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| } | ||
| ], | ||
| "primaryKey": { | ||
| "autoGenerate": false, | ||
| "columnNames": [ | ||
| "uniqueKey" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "tableName": "TokenDeviceBinding", | ||
| "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`userId` INTEGER NOT NULL, `androidId` TEXT NOT NULL, PRIMARY KEY(`userId`), FOREIGN KEY(`userId`) REFERENCES `User`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", | ||
| "fields": [ | ||
| { | ||
| "fieldPath": "userId", | ||
| "columnName": "userId", | ||
| "affinity": "INTEGER", | ||
| "notNull": true | ||
| }, | ||
| { | ||
| "fieldPath": "androidId", | ||
| "columnName": "androidId", | ||
| "affinity": "TEXT", | ||
| "notNull": true | ||
| } | ||
| ], | ||
| "primaryKey": { | ||
| "autoGenerate": false, | ||
| "columnNames": [ | ||
| "userId" | ||
| ] | ||
| }, | ||
| "foreignKeys": [ | ||
| { | ||
| "table": "User", | ||
| "onDelete": "CASCADE", | ||
| "onUpdate": "NO ACTION", | ||
| "columns": [ | ||
| "userId" | ||
| ], | ||
| "referencedColumns": [ | ||
| "id" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "setupQueries": [ | ||
| "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", | ||
| "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6d4be66bdbd5459afb46f129e14738f7')" | ||
| ] | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
45 changes: 45 additions & 0 deletions
45
Auth/src/main/kotlin/com/infomaniak/core/auth/DerivedTokenGenerator.IssueExtensions.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Infomaniak Core - Android | ||
| * Copyright (C) 2026 Infomaniak Network SA | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.infomaniak.core.auth | ||
|
|
||
| import com.infomaniak.core.appintegrity.AppIntegrityIssue | ||
| import com.infomaniak.core.auth.DerivedTokenGenerator.Issue | ||
|
|
||
| fun Issue.shouldReport(): Boolean = when (this) { | ||
| is Issue.AppIntegrityCheckFailed -> false | ||
| is Issue.ErrorResponse -> response.code !in 500..599 | ||
| is Issue.NetworkIssue -> false | ||
| is Issue.OtherIssue -> true | ||
| } | ||
|
|
||
| fun Issue.shouldRetryAutomatically(): Boolean = when (this) { | ||
| is Issue.AppIntegrityCheckFailed -> shouldRetryAutomatically() | ||
| is Issue.ErrorResponse -> shouldRetryAutomatically() | ||
| is Issue.NetworkIssue -> true | ||
| is Issue.OtherIssue -> false | ||
| } | ||
|
|
||
| private fun Issue.AppIntegrityCheckFailed.shouldRetryAutomatically(): Boolean = when (details.issue) { | ||
| is AppIntegrityIssue.RetryLater, is AppIntegrityIssue.Internal -> true | ||
| is AppIntegrityIssue.DeviceIssue, is AppIntegrityIssue.DevError, is AppIntegrityIssue.SuspiciousError -> false | ||
| } | ||
|
|
||
| private fun Issue.ErrorResponse.shouldRetryAutomatically(): Boolean = when (response.code) { | ||
| 400, 401 -> false | ||
| else -> true | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.