-
Notifications
You must be signed in to change notification settings - Fork 155
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 verification failed issue, simplify verification logic #3830
Conversation
- Reuse Rust `Client` instances created on the login process so we don't need to restore one right before the session verification. - Remove unnecessary sources of verification state updates. - Add an intermediate FTUE flow step which will display an indeterminate progress indicator instead of a blank screen.
// Otherwise, just check the current verification status from the session verification controller instead | ||
Timber.d("Updating verification status: flow is pending or was finished some time ago") | ||
runCatching { | ||
initVerificationControllerIfNeeded() |
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.
This line here is what caused the automatic verification failure if it was called before the verification service was ready.
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
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.
A first few remarks.
features/ftue/impl/src/main/kotlin/io/element/android/features/ftue/impl/FtueFlowNode.kt
Outdated
Show resolved
Hide resolved
.../ftue/impl/src/main/kotlin/io/element/android/features/ftue/impl/state/DefaultFtueService.kt
Show resolved
Hide resolved
...src/main/kotlin/io/element/android/libraries/matrix/api/auth/ClientAuthenticationObserver.kt
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3830 +/- ##
===========================================
- Coverage 82.98% 82.98% -0.01%
===========================================
Files 1783 1783
Lines 44971 44980 +9
Branches 5289 5293 +4
===========================================
+ Hits 37320 37327 +7
+ Misses 5805 5803 -2
- Partials 1846 1850 +4 ☔ View full report in Codecov by Sentry. |
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.
Some remarks, still testing on my side
...main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt
Outdated
Show resolved
Hide resolved
...main/kotlin/io/element/android/libraries/matrix/impl/auth/RustMatrixAuthenticationService.kt
Outdated
Show resolved
Hide resolved
...src/main/kotlin/io/element/android/libraries/matrix/api/auth/ClientAuthenticationObserver.kt
Outdated
Show resolved
Hide resolved
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.
I'll merge develop on it and do more test, but it looks OK!
@@ -81,4 +81,17 @@ class MatrixClientsHolderTest { | |||
matrixClientsHolder.restoreWithSavedState(savedStateMap) | |||
assertThat(matrixClientsHolder.getOrNull(A_SESSION_ID)).isEqualTo(fakeMatrixClient) | |||
} | |||
|
|||
@Test | |||
fun `test ClientAuthenticationObserver emits a value and we save it`() = runTest { |
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.
Maybe rename this test now that ClientAuthenticationObserver
has been deleted.
} | ||
.first() | ||
return readyVerifiedSessionStatus == SessionVerifiedStatus.NotVerified && !canSkipVerification() | ||
// Wait until the session verification status is known |
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.
Neat: the @OptIn
can be removed.
* In this case, the FTUE flow is ready when the session verification status is known. | ||
*/ | ||
@OptIn(FlowPreview::class) | ||
val isVerificationStatusKnown = sessionVerificationService.sessionVerifiedStatus |
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.
Neat: the @OptIn
can be removed (twice in this file).
analyticsService = analyticsService, | ||
permissionStateProvider = permissionStateProvider, | ||
lockScreenService = lockScreenService, | ||
) |
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.
Thanks for this new test!
Quality Gate passedIssues Measures |
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.
Thanks for the update.
I have done more tests and this seems to be fine.
We will need to handle the problem when Element Web is accepting an incoming verification request even if it does not know the private key. In this case, the Element X session will not become verified.
This is tracked by element-hq/element-web#27655
Content
initVerificationControllerIfNeeded
call which caused the automatic verification flow failure.Client
instances created on the login process so we don't need to restore one right before the session verification.Motivation and context
This should fix the issues we've seen where the authentication failed automatically due to a race condition.
Keeping the Client instances created on login would also make our setup more similar to iOS and avoid unnecessary work.
Tests
Tested devices
Checklist