Skip to content
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

Feature: identity reset #3298

Merged
merged 15 commits into from
Aug 16, 2024
Merged

Feature: identity reset #3298

merged 15 commits into from
Aug 16, 2024

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Aug 12, 2024

Content

  • Moves OIDC related code to their own modules: libraries/oidc.
  • Improves the custom chrome tab implementation and fixes issues with the fallback webview one (it was freezing after signing in).
  • Creates OidcEntryPoint which allows opening any of the OIDC flow options (custom tab, webview).
  • Adds new flows for identity reset: root screen with confirmation, OIDC one which uses the extracted OIDC logic, user+password one.
  • Create IdentityResetHandle wrappers for both OIDC and password variants.

Motivation and context

Closes #3268.

Screenshots / GIFs

In the PR.

Tests

With a user + password based account whose data you don't mind losing:

  • Log in.
  • Select 'Can't confirm?'.
  • Continue, add your password and confirm.
  • You should be fully logged in now and the system will ask you to add key backup.

With an OIDC one (maybe using synapse-oidc.element.dev?):

  • Log in.
  • Select 'Can't confirm?'.
  • Continue, confirm the reset in the custom tab/webview, then go back.
  • You should be fully logged in now and the system will ask you to add key backup.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 13

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

@jmartinesp jmartinesp added the PR-Feature For a new feature label Aug 12, 2024
Copy link
Contributor

github-actions bot commented Aug 12, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/gRd5UA

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 84.92647% with 41 lines in your changes missing coverage. Please review.

Project coverage is 82.56%. Comparing base (45775d7) to head (99efdb6).
Report is 17 commits behind head on develop.

Files Patch % Lines
...nt/android/libraries/oidc/impl/webview/OidcView.kt 52.63% 8 Missing and 1 partial ⚠️
...droid/libraries/oidc/impl/DefaultOidcEntryPoint.kt 0.00% 8 Missing ⚠️
.../matrix/test/encryption/FakeIdentityResetHandle.kt 44.44% 5 Missing ⚠️
...p/impl/reset/password/ResetIdentityPasswordView.kt 91.30% 0 Missing and 4 partials ⚠️
.../libraries/androidutils/browser/ChromeCustomTab.kt 0.00% 4 Missing ⚠️
...ecurebackup/impl/reset/ResetIdentityFlowManager.kt 87.50% 0 Missing and 3 partials ⚠️
...l/reset/password/ResetIdentityPasswordPresenter.kt 87.50% 1 Missing and 1 partial ⚠️
.../impl/reset/root/ResetIdentityRootStateProvider.kt 75.00% 2 Missing ⚠️
...eatures/securebackup/api/SecureBackupEntryPoint.kt 0.00% 1 Missing ⚠️
...ckup/impl/reset/root/ResetIdentityRootPresenter.kt 88.88% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3298      +/-   ##
===========================================
- Coverage    82.56%   82.56%   -0.01%     
===========================================
  Files         1662     1675      +13     
  Lines        38992    39204     +212     
  Branches      4724     4745      +21     
===========================================
+ Hits         32193    32367     +174     
- Misses        5133     5163      +30     
- Partials      1666     1674       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp jmartinesp marked this pull request as ready for review August 13, 2024 06:47
@jmartinesp jmartinesp requested a review from a team as a code owner August 13, 2024 06:47
@jmartinesp jmartinesp requested review from bmarty and removed request for a team August 13, 2024 06:47
@jmartinesp jmartinesp force-pushed the feat/jme/3268-crypto-identity-reset branch from de7f819 to d5eb71a Compare August 13, 2024 06:55
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few first remarks.

I have tested the reset using password, it's working as expected.
Also tested using Oidc, working as expected.

} else if (state.resetAction.isFailure()) {
ErrorDialog(
content = stringResource(CommonStrings.error_unknown),
onDismiss = { state.eventSink(ResetIdentityPasswordEvent.DismissError) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we inline the error in the password field when the password is not correct?
We may also want to improve the error message in this case:

image

Note that the error in this case is not very explicit: the server returned an error: User-Interactive Authentication required.

modifier = Modifier.fillMaxWidth(),
text = stringResource(CommonStrings.action_reset_identity),
onClick = { state.eventSink(ResetIdentityPasswordEvent.Reset(passwordState.value)) },
destructive = true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe disable the button when the password is empty?

image

},
destructiveSubmit = true,
onDismiss = { state.eventSink(ResetIdentityRootEvent.DismissDialog) }
)
Copy link
Member

@bmarty bmarty Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a wording inconsistency: will the user reset encryption or identity (whatever this may mean for a non-technical user...)

image

Note: on OIDC web page this is yet another wording:

image

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, your first screen is outdated. Figma designs have been updated since.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this one?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this one?

I meant the first one of this post.

But the one you mentioned is actually outdated in the designs, yes. It should say "go to your account to reset your identity".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have requested to access the Figma file (again)

lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onStart(owner: LifecycleOwner) {
// If the custom tab was opened, we need to cancel the reset job
// when we come back to the node if it the reset wasn't successful
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// when we come back to the node if it the reset wasn't successful
// when we come back to the node if the reset wasn't successful

val handle = resetIdentityFlowManager.getResetHandle()
.filterIsInstance<AsyncData.Success<IdentityResetHandle>>()
.first()
.data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will ignore any Failure coming in the flow. Can it be a problem?
Maybe add a log, just in case...

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2023 New Vector Ltd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright (c) 2023 New Vector Ltd
* Copyright (c) 2024 New Vector Ltd

@@ -0,0 +1,71 @@
/*
* Copyright (c) 2022 New Vector Ltd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright (c) 2022 New Vector Ltd
* Copyright (c) 2024 New Vector Ltd

testImplementation(projects.libraries.matrix.test)
testImplementation(projects.libraries.permissions.test)
testImplementation(projects.tests.testutils)
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some unused dependencies can be removed here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wording: reset encryption or reset identity?

val currentHandleFlow: StateFlow<AsyncData<IdentityResetHandle>> = resetHandleFlow

fun whenResetIsDone(block: () -> Unit) {
sessionCoroutineScope.launch {
Copy link
Member

@bmarty bmarty Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to cancel this job if the user click go back instead of going to the end of the flow (or use the presenter / node scope)

Copy link

Copy link
Member

@bmarty bmarty left a 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!

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Aug 14, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Aug 14, 2024
@bmarty bmarty merged commit b62348f into develop Aug 16, 2024
28 of 29 checks passed
@bmarty bmarty deleted the feat/jme/3268-crypto-identity-reset branch August 16, 2024 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Feature For a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Story] Crypto identity reset
3 participants