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

Sign in with QR code #2793

Merged
merged 67 commits into from
May 31, 2024
Merged

Sign in with QR code #2793

merged 67 commits into from
May 31, 2024

Conversation

jmartinesp
Copy link
Contributor

@jmartinesp jmartinesp commented May 3, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

  • Bumped SDK version to be able to use new APIs.
  • Added changes to :libraries:matrix modules to map data from/to the Rust SDK and perform a QR code login.
  • Added the new screens for this feature.
  • Moved OnboardingConfig to :appconfig.
  • Added a FF for this feature, disabled by default in release, enabled by default in debug and nightly.
  • Replaced our Zxing library with Zxing-CPP which was re-built in native code and is faster and more accurate (Zxing, or at least the version we had to use was outdated and didn't work well with some generated QRs).
  • Made sure the login flow can only be used in portrait mode (the landscape one was broken in most devices anyway).
  • Fixed some issues (thanks @bmarty for the early review!).
  • Added tests for the new code.

Motivation and context

Closes #2632.

Screenshots / GIFs

Lots in the PR.

Tests

  • Create an account in https://pr12370--matrix-react-sdk.netlify.app/.
  • In that version of EW, go to settings -> labs -> scroll to the bottom and enabled native OIDC login.
  • On the EX app, tap on sign in with QR code and follow the instructions.
  • You should be able to login using the QR code. And if you have any issues you should be able to restart the login attempt.

Tested devices

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

Checklist

bmarty and others added 30 commits April 10, 2024 09:30
- Force portrait orientation on the login flow.
- Create `NumberedList` UI components.
- Improve camera permission dialog.
- Improve how the QR code preview is rendered.
- Freeze the last frame of the preview when a QR code is read.
- Update `FlowStepPage` contents to fit the new designs.
- Update strings in UI.
This needs `jme/qr-login-for-testing-with-clients` branch in the rust-sdk project
Rename `QrCodeLoginPresenter` to `QrCodeLoginManager`, since it's not really a presenter.
@jmartinesp jmartinesp marked this pull request as ready for review May 29, 2024 16:33
@jmartinesp jmartinesp requested a review from a team as a code owner May 29, 2024 16:33
@jmartinesp jmartinesp requested review from ganfra and removed request for a team May 29, 2024 16:33
Copy link
Contributor

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

Good work!
Have not tested yet, but I'll.
Some small remarks/questions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Button is close to the CameraView?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

6ff42bc, I thought it was going to be harder to fix.

@@ -75,6 +77,7 @@ class NotLoggedInFlowNode @AssistedInject constructor(
@Parcelize
data class LoginFlow(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not be an enum? I don't think we can have both to true, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


@SingleIn(QrCodeLoginScope::class)
@MergeSubcomponent(QrCodeLoginScope::class)
interface QrCodeLoginComponent : NodeFactoriesBindings {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need a separate component and scope for this? This is just to keep the StateFlow<QrCodeLoginStep>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem here is QrCodeLoginManager had to be shared by several components (QrCodeLofingFlowNode, QrCodeScanPresenter) and for that I needed a singleton if I'm not mistaken. But having a singleton can be troublesome if you aren't super careful with cleaning up its state once you're done working with it, so I created a new component to hold it that will be created when the QR code flow starts and discarded once it's finished.

This should ensure the object is shared but can't be leaked in any way, although it's more complex than I intended it to be.

import io.element.android.libraries.architecture.inputs
import io.element.android.libraries.di.AppScope

@ContributesNode(AppScope::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use QrCodeLoginScope?

import io.element.android.libraries.core.meta.BuildMeta
import io.element.android.libraries.di.AppScope

@ContributesNode(AppScope::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use QrCodeLoginScope?

import io.element.android.anvilannotations.ContributesNode
import io.element.android.libraries.di.AppScope

@ContributesNode(AppScope::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use QrCodeLoginScope?

@@ -42,6 +43,7 @@ class StaticFeatureFlagProvider @Inject constructor() :
FeatureFlags.MarkAsUnread -> true
FeatureFlags.RoomDirectorySearch -> false
FeatureFlags.ShowBlockedUsersDetails -> false
FeatureFlags.QrCodeLogin -> OnBoardingConfig.CAN_LOGIN_WITH_QR_CODE
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer the value to be directly here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're probably going to remove the feature flag soon-ish and go back to the build config constant, so I made this compromise because I didn't want to remove the constant just to add it back later or have 1 value that actually does something (FF here) and another that does nothing at the same time.

@jmartinesp
Copy link
Contributor Author

Can we retest this @bmarty, @ganfra and merge it if it's fine?

@jmartinesp jmartinesp force-pushed the feature/bma/signInWithQrCode branch from 68efc1f to 6b5e558 Compare May 31, 2024 10:31
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.

I guess it's fine since the feature is still disabled (CAN_LOGIN_WITH_QR_CODE = false)

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 31, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 31, 2024
@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 31, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 31, 2024
Copy link

sonarcloud bot commented May 31, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@hughns
Copy link
Member

hughns commented May 31, 2024

I've tested the latest build against synapse-oidc.lab.element.dev with no issues found.

@jmartinesp jmartinesp merged commit c8bd04c into develop May 31, 2024
25 checks passed
@jmartinesp jmartinesp deleted the feature/bma/signInWithQrCode branch May 31, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Sign in with QR code
5 participants