Skip to content

Commit e6dc24a

Browse files
committed
feat: Add support to log in using a QR code
This implements one part of MSC4108[1], it implements the case where the new device scans the QR code. [1]: matrix-org/matrix-spec-proposals#4108
1 parent 05f9f85 commit e6dc24a

File tree

14 files changed

+2791
-7
lines changed

14 files changed

+2791
-7
lines changed

.typos.toml

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ ratatui = "ratatui"
2525
# base64 false positives
2626
Nd = "Nd"
2727
Abl = "Abl"
28+
Som = "Som"
29+
Ba = "Ba"
2830

2931
[files]
3032
extend-exclude = [

Cargo.lock

+83-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ tracing-core = "0.1.32"
6767
uniffi = { version = "0.27.1" }
6868
uniffi_bindgen = { version = "0.27.1" }
6969
url = "2.5.0"
70-
vodozemac = { git = "https://github.com/matrix-org/vodozemac/", rev = "826d0aa22a9b5405535927c7691492db4b92a43b" }
70+
vodozemac = { git = "https://github.com/matrix-org/vodozemac/", rev = "4ef989c6a8eba0bc809e285a081c56320a9bbf1e" }
7171
wiremock = "0.6.0"
7272
zeroize = "1.6.0"
7373

crates/matrix-sdk/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Breaking changes:
1818

1919
Additions:
2020

21+
- Expose new method `Client::Oidc::login_with_qr_code()`.
22+
([#3466](https://github.com/matrix-org/matrix-rust-sdk/pull/3466))
2123
- Add the `ClientBuilder::add_root_certificates()` method which re-exposes the
2224
`reqwest::ClientBuilder::add_root_certificate()` functionality.
2325
- Add `Room::get_user_power_level(user_id)` and `Room::get_suggested_user_role(user_id)` to be able to fetch power level info about an user without loading the room member list.

crates/matrix-sdk/Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ uniffi = ["dep:uniffi", "matrix-sdk-base/uniffi"]
4545

4646
experimental-oidc = [
4747
"ruma/unstable-msc2967",
48+
"ruma/unstable-msc4108",
4849
"dep:chrono",
4950
"dep:http_old",
5051
"dep:language-tags",
@@ -72,6 +73,7 @@ async-channel = "2.2.1"
7273
async-stream = { workspace = true }
7374
async-trait = { workspace = true }
7475
axum = { version = "0.7.4", optional = true }
76+
base64 = { workspace = true }
7577
bytes = "1.1.0"
7678
bytesize = "1.1"
7779
chrono = { version = "0.4.23", optional = true }
@@ -108,9 +110,10 @@ tokio-stream = { workspace = true, features = ["sync"] }
108110
tower = { version = "0.4.13", features = ["make"], optional = true }
109111
tracing = { workspace = true, features = ["attributes"] }
110112
uniffi = { workspace = true, optional = true }
111-
url = { workspace = true }
113+
url = { workspace = true, features = ["serde"] }
112114
urlencoding = "2.1.3"
113115
uuid = { version = "1.4.1", features = ["serde", "v4"], optional = true }
116+
vodozemac = { workspace = true }
114117
zeroize = { workspace = true }
115118

116119
[dependencies.image]
@@ -126,6 +129,7 @@ tokio = { workspace = true, features = ["macros"] }
126129

127130
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
128131
backoff = { version = "0.4.0", features = ["tokio"] }
132+
openidconnect = { git = "https://github.com/poljar/openidconnect-rs", rev = "c7e1dc31b83dd7559125984bfd36b9c0f191585e" }
129133
# only activate reqwest's stream feature on non-wasm, the wasm part seems to not
130134
# support *sending* streams, which makes it useless for us.
131135
reqwest = { workspace = true, features = ["stream"] }
@@ -144,6 +148,7 @@ matrix-sdk-base = { workspace = true, features = ["testing"] }
144148
matrix-sdk-test = { workspace = true }
145149
once_cell = { workspace = true }
146150
serde_urlencoded = "0.7.1"
151+
similar-asserts = "1.5.0"
147152
stream_assert = { workspace = true }
148153
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
149154

crates/matrix-sdk/src/authentication/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//! Types and functions related to authentication in Matrix.
16+
1517
// TODO:(pixlwave) Move AuthenticationService from the FFI into this module.
18+
// TODO:(poljar) Move the oidc and matrix_auth modules under this module.
1619

1720
use std::pin::Pin;
1821

@@ -28,6 +31,9 @@ use crate::{
2831
Client, RefreshTokenError, SessionChange,
2932
};
3033

34+
#[cfg(all(feature = "experimental-oidc", feature = "e2e-encryption", not(target_arch = "wasm32")))]
35+
pub mod qrcode;
36+
3137
/// Session tokens, for any kind of authentication.
3238
#[allow(missing_debug_implementations, clippy::large_enum_variant)]
3339
pub enum SessionTokens {

0 commit comments

Comments
 (0)