Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

MSC4108 support OIDC QR code login #12370

Merged
merged 120 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 111 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
d625b61
WIP prototype of MSC4108
hughns Mar 14, 2024
40ae685
Async import rendezvous bits as they include the rust crypto wasm blob
t3chguy Mar 14, 2024
096f2f3
Iterate PR
t3chguy Mar 14, 2024
74f7621
Switch to generating/parsing MSC4108 QR codes via Rust Crypto
t3chguy Mar 18, 2024
94dd62b
Wait until secure channel is confirmed before doing OIDC registration
hughns Mar 20, 2024
74000bb
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Mar 21, 2024
8f6174a
Wire up rust-crypto qr secrets import/export
t3chguy Mar 22, 2024
7055165
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Mar 22, 2024
274999c
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Mar 25, 2024
fbfb0f4
Shuttle secrets via credentials and avoid calling doSetLoggedIn twice
t3chguy Mar 25, 2024
62d3e7a
Restore key backup after importing QR secrets
t3chguy Mar 25, 2024
02154ab
Remove unused method
t3chguy Mar 25, 2024
b4cd325
Delint
t3chguy Mar 25, 2024
6054a71
i18n
t3chguy Mar 25, 2024
2b8ffa3
Ensure rust crypto wasm is loaded async
t3chguy Mar 25, 2024
887a2b9
Remove changes which rely on major oidc-client-ts upstream changes
t3chguy Mar 25, 2024
99b5213
Prettier
t3chguy Mar 25, 2024
fda2898
Remove login qr flows
t3chguy Mar 26, 2024
a7ba73b
Simplify
t3chguy Mar 26, 2024
f808b49
Restore legacy QR code login
t3chguy Mar 26, 2024
0874348
Iterate
t3chguy Mar 26, 2024
31ac294
Iterate
t3chguy Mar 26, 2024
e01610e
Iterate
t3chguy Mar 26, 2024
97c1fe8
i18n
t3chguy Mar 26, 2024
179a7d9
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Mar 26, 2024
0d341af
Add test
t3chguy Mar 26, 2024
e319b3c
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Mar 27, 2024
a5e8b37
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Apr 5, 2024
c2248e7
Prototype of requiring CheckCode
hughns Mar 26, 2024
ee5fced
Split display of secure channel confirmation code and Device Authoriz…
hughns Apr 2, 2024
af4b661
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Apr 8, 2024
13045da
Iterate UX
t3chguy Apr 9, 2024
7d7ecf5
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Apr 12, 2024
f30dc40
Handle additional rendezvous failure reasons
hughns Apr 10, 2024
437bbcb
Rename data_mismatch to insecure_channel_detected
hughns Apr 10, 2024
0246022
Update failure reasons to match MSC
hughns Apr 10, 2024
c149893
Test deeper
t3chguy Apr 15, 2024
41f9178
Fix types
t3chguy Apr 17, 2024
38b3882
i18n
t3chguy Apr 17, 2024
e32136f
Gate OIDC QR on OIDC Native labs flag
t3chguy Apr 17, 2024
62d8373
Iterate QR OIDC UX
t3chguy Apr 18, 2024
4a8f76d
Split error for UserDeclined
t3chguy Apr 18, 2024
e592fae
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Apr 18, 2024
353d9f5
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Apr 18, 2024
f810b68
i18n
t3chguy Apr 18, 2024
f0c88a2
Fudge yarn.lock
t3chguy Apr 18, 2024
72fe90d
Copy prepare hack
t3chguy Apr 18, 2024
83935e7
Try s'more
t3chguy Apr 18, 2024
e86d0c3
Try s'more
t3chguy Apr 18, 2024
932b2fc
Try s'more
t3chguy Apr 18, 2024
8bec40f
Try s'more
t3chguy Apr 18, 2024
fbcac6c
Try s'more
t3chguy Apr 18, 2024
e5b9c5d
Update snapshots
t3chguy Apr 18, 2024
6dbdaf2
Fix tests
t3chguy Apr 18, 2024
f694f6d
Fix tests
t3chguy Apr 18, 2024
96b6a05
Iterate
t3chguy Apr 19, 2024
0ce0237
Fix styling
t3chguy Apr 19, 2024
5e3f6e8
Fix styling
t3chguy Apr 19, 2024
2c767cc
Iterate
t3chguy Apr 22, 2024
ec762bb
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Apr 22, 2024
2e16695
Iterate
t3chguy Apr 22, 2024
f9b388e
Fix tests
t3chguy Apr 22, 2024
7542768
Require cross-signing to be ready for oidc-qr login
t3chguy Apr 23, 2024
04fd153
Handle etag missing state
t3chguy Apr 23, 2024
2a01e2f
Improve coverage
t3chguy Apr 23, 2024
eb89328
Update snapshots
t3chguy Apr 24, 2024
b6e79d6
Improve coverage
t3chguy Apr 24, 2024
9150366
Improve coverage
t3chguy Apr 24, 2024
c49311b
Improve coverage
t3chguy Apr 24, 2024
580ab9f
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Apr 24, 2024
efb9e89
Improve coverage
t3chguy Apr 24, 2024
aa658a5
Improve docs
t3chguy Apr 24, 2024
20cae74
Tidy
t3chguy Apr 24, 2024
62fd3bd
Tidy
t3chguy Apr 24, 2024
ff1d334
Iterate
t3chguy Apr 24, 2024
2f81f56
Iterate
t3chguy Apr 25, 2024
a736e67
XXX: Add `Link new device` to User Menu
t3chguy Apr 25, 2024
b4f8cac
XXX iterate
t3chguy Apr 25, 2024
4af535c
Don't use validated_server_config as that is only set for OIDC-native
t3chguy Apr 25, 2024
f6f64e8
Fix tests
t3chguy Apr 26, 2024
791b346
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Apr 26, 2024
86cd325
Fix "Link New Device" action
t3chguy Apr 26, 2024
bfce452
i18n
t3chguy Apr 26, 2024
48f5e67
Clear show qr code state when navigating tabs
t3chguy Apr 26, 2024
d6400ee
Ensure the channel is not cancelled when the flow is concluded
t3chguy Apr 26, 2024
f6bfa5d
Improve coverage
t3chguy Apr 26, 2024
ecb1bc3
Fix test
t3chguy Apr 26, 2024
7ee252c
Fix styling bug
t3chguy Apr 29, 2024
c306b35
Update copy
t3chguy Apr 29, 2024
79ad9a2
Update snapshot
t3chguy Apr 29, 2024
0569ac1
Update copy
t3chguy Apr 29, 2024
2788b10
Update snapshot
t3chguy Apr 29, 2024
2e8f4ec
Remove redundant (for now) scanning code
t3chguy May 1, 2024
501bb52
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy May 1, 2024
a213f2c
delint
t3chguy May 1, 2024
9b6fcac
Cull more early code
t3chguy May 1, 2024
6998dea
Tidy
t3chguy May 1, 2024
4105dfa
Fix error handling
t3chguy May 1, 2024
fd0cf4b
Merge branch 'develop' into t3chguy/oidc-qr-prototyping
t3chguy May 3, 2024
d97ee26
Bump @matrix-org/matrix-sdk-crypto-wasm to 90b63b84df65c19161f94049d8…
t3chguy May 7, 2024
4bc21bd
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy May 7, 2024
88efbc7
i18n
t3chguy May 7, 2024
57cc27d
Tweak copy
t3chguy May 9, 2024
d7b5035
Merge branch 'develop' into t3chguy/oidc-qr-prototyping
t3chguy May 14, 2024
f0c6272
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy May 23, 2024
8129f50
Discard changes to yarn.lock
t3chguy May 23, 2024
c5d61a2
i18n
t3chguy May 23, 2024
a66d1bf
Iterate
t3chguy May 23, 2024
80c31e2
Iterate
t3chguy May 23, 2024
d9b3c4d
Merge branch 'develop' into t3chguy/oidc-qr-prototyping
t3chguy May 24, 2024
34223b2
Skip checkQrLoginSupport if OIDC labs flag is not enabled
t3chguy May 28, 2024
9f2afe0
Use RendezvousError.code as failure reason during approveLogin()
hughns May 31, 2024
fe0d014
Lint
hughns May 31, 2024
07e2c07
Update copy
t3chguy May 31, 2024
3619e27
Merge remote-tracking branch 'origin/t3chguy/oidc-qr-prototyping' int…
t3chguy May 31, 2024
8eb5d1b
Update snapshot
t3chguy May 31, 2024
4113ec0
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Jun 5, 2024
14275a5
Iterate
t3chguy Jun 5, 2024
5fa8598
Iterate
t3chguy Jun 5, 2024
fb59a0c
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ module.exports = {
"!matrix-js-sdk/src/secret-storage",
"!matrix-js-sdk/src/room-hierarchy",
"!matrix-js-sdk/src/rendezvous",
"!matrix-js-sdk/src/rendezvous/transports",
"!matrix-js-sdk/src/rendezvous/channels",
"!matrix-js-sdk/src/indexeddb-worker",
"!matrix-js-sdk/src/pushprocessor",
"!matrix-js-sdk/src/extensible_events_v1",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
cache: "yarn"

- name: Install Deps
run: "./scripts/ci/install-deps.sh --ignore-scripts"
run: "./scripts/ci/install-deps.sh"

- name: Typecheck
run: "yarn run lint:types"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
cache: "yarn"

- name: Install Deps
run: "./scripts/ci/install-deps.sh --ignore-scripts"
run: "./scripts/ci/install-deps.sh"
env:
JS_SDK_GITHUB_BASE_REF: ${{ inputs.matrix-js-sdk-sha }}

Expand Down
4 changes: 4 additions & 0 deletions res/css/structures/_UserMenu.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ limitations under the License.
.mx_UserMenu_iconSignOut::before {
mask-image: url("$(res)/img/element-icons/leave.svg");
}

.mx_UserMenu_iconQr::before {
mask-image: url("@vector-im/compound-design-tokens/icons/qr-code.svg");
}
}

.mx_UserMenu_CustomStatusSection {
Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
const tabPayload = payload as OpenToTabPayload;
Modal.createDialog(
UserSettingsDialog,
{ initialTabId: tabPayload.initialTabId as UserTab, sdkContext: this.stores },
{ ...payload.props, initialTabId: tabPayload.initialTabId as UserTab, sdkContext: this.stores },
/*className=*/ undefined,
/*isPriority=*/ false,
/*isStatic=*/ true,
Expand Down
60 changes: 57 additions & 3 deletions src/components/structures/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import React, { createRef, ReactNode } from "react";
import { Room } from "matrix-js-sdk/src/matrix";
import { discoverAndValidateOIDCIssuerWellKnown, Room } from "matrix-js-sdk/src/matrix";

import { MatrixClientPeg } from "../../MatrixClientPeg";
import defaultDispatcher from "../../dispatcher/dispatcher";
Expand Down Expand Up @@ -52,6 +52,8 @@ import { Icon as LiveIcon } from "../../../res/img/compound/live-8px.svg";
import { VoiceBroadcastRecording, VoiceBroadcastRecordingsStoreEvent } from "../../voice-broadcast";
import { SDKContext } from "../../contexts/SDKContext";
import { shouldShowFeedback } from "../../utils/Feedback";
import { shouldShowQr } from "../views/settings/devices/LoginWithQRSection";
import { Features } from "../../settings/Settings";

interface IProps {
isPanelCollapsed: boolean;
Expand All @@ -66,6 +68,8 @@ interface IState {
isHighContrast: boolean;
selectedSpace?: Room | null;
showLiveAvatarAddon: boolean;
showQrLogin: boolean;
supportsQrLogin: boolean;
}

const toRightOf = (rect: PartialDOMRect): MenuProps => {
Expand Down Expand Up @@ -103,6 +107,8 @@ export default class UserMenu extends React.Component<IProps, IState> {
isHighContrast: this.isUserOnHighContrastTheme(),
selectedSpace: SpaceStore.instance.activeSpaceRoom,
showLiveAvatarAddon: this.context.voiceBroadcastRecordingsStore.hasCurrent(),
showQrLogin: false,
supportsQrLogin: false,
};

OwnProfileStore.instance.on(UPDATE_EVENT, this.onProfileUpdate);
Expand All @@ -126,6 +132,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
);
this.dispatcherRef = defaultDispatcher.register(this.onAction);
this.themeWatcherRef = SettingsStore.watchSetting("theme", null, this.onThemeChanged);
this.checkQrLoginSupport();
}

public componentWillUnmount(): void {
Expand All @@ -140,6 +147,29 @@ export default class UserMenu extends React.Component<IProps, IState> {
);
}

private checkQrLoginSupport = async (): Promise<void> => {
if (!this.context.client || !SettingsStore.getValue(Features.OidcNativeFlow)) return;

const { issuer } = await this.context.client.getAuthIssuer().catch(() => ({ issuer: undefined }));
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
if (issuer) {
const [oidcClientConfig, versions, wellKnown, isCrossSigningReady] = await Promise.all([
discoverAndValidateOIDCIssuerWellKnown(issuer),
this.context.client.getVersions(),
this.context.client.waitForClientWellKnown(),
this.context.client.getCrypto()?.isCrossSigningReady(),
]);

const supportsQrLogin = shouldShowQr(
this.context.client,
!!isCrossSigningReady,
oidcClientConfig,
versions,
wellKnown,
);
this.setState({ supportsQrLogin, showQrLogin: true });
}
};

private isUserOnDarkTheme(): boolean {
if (SettingsStore.getValue("use_system_theme")) {
return window.matchMedia("(prefers-color-scheme: dark)").matches;
Expand Down Expand Up @@ -237,11 +267,11 @@ export default class UserMenu extends React.Component<IProps, IState> {
SettingsStore.setValue("theme", null, SettingLevel.DEVICE, newTheme); // set at same level as Appearance tab
};

private onSettingsOpen = (ev: ButtonEvent, tabId?: string): void => {
private onSettingsOpen = (ev: ButtonEvent, tabId?: string, props?: Record<string, any>): void => {
ev.preventDefault();
ev.stopPropagation();

const payload: OpenToTabPayload = { action: Action.ViewUserSettings, initialTabId: tabId };
const payload: OpenToTabPayload = { action: Action.ViewUserSettings, initialTabId: tabId, props };
defaultDispatcher.dispatch(payload);
this.setState({ contextMenuPosition: null }); // also close the menu
};
Expand Down Expand Up @@ -363,9 +393,33 @@ export default class UserMenu extends React.Component<IProps, IState> {
);
}

let linkNewDeviceButton: JSX.Element | undefined;
if (this.state.showQrLogin) {
const extraProps: Omit<
React.ComponentProps<typeof IconizedContextMenuOption>,
"iconClassname" | "label" | "onClick"
> = {};
if (!this.state.supportsQrLogin) {
extraProps.disabled = true;
extraProps.title = _t("user_menu|link_new_device_not_supported");
extraProps.caption = _t("user_menu|link_new_device_not_supported_caption");
extraProps.placement = "right";
}

linkNewDeviceButton = (
<IconizedContextMenuOption
{...extraProps}
iconClassName="mx_UserMenu_iconQr"
label={_t("user_menu|link_new_device")}
onClick={(e) => this.onSettingsOpen(e, UserTab.SessionManager, { showMsc4108QrCode: true })}
/>
);
}

let primaryOptionList = (
<IconizedContextMenuOptionList>
{homeButton}
{linkNewDeviceButton}
<IconizedContextMenuOption
iconClassName="mx_UserMenu_iconBell"
label={_t("notifications|enable_prompt_toast_title")}
Expand Down
10 changes: 7 additions & 3 deletions src/components/views/auth/LoginWithQR-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ export enum Mode {
export enum Phase {
Loading,
ShowingQR,
Connecting,
Connected,
// The following are specific to MSC4108
OutOfBandConfirmation,
WaitingForDevice,
Verifying,
Error,
/**
* @deprecated the MSC3906 implementation is deprecated in favour of MSC4108.
*/
LegacyConnected,
}

export enum Click {
Cancel,
Decline,
Approve,
TryAgain,
Back,
ShowQr,
}
Loading
Loading