Skip to content

Commit

Permalink
feat: Add support to log in using a QR code
Browse files Browse the repository at this point in the history
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
  • Loading branch information
poljar committed May 28, 2024
1 parent 05f9f85 commit e6dc24a
Show file tree
Hide file tree
Showing 14 changed files with 2,791 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ratatui = "ratatui"
# base64 false positives
Nd = "Nd"
Abl = "Abl"
Som = "Som"
Ba = "Ba"

[files]
extend-exclude = [
Expand Down
85 changes: 83 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ tracing-core = "0.1.32"
uniffi = { version = "0.27.1" }
uniffi_bindgen = { version = "0.27.1" }
url = "2.5.0"
vodozemac = { git = "https://github.com/matrix-org/vodozemac/", rev = "826d0aa22a9b5405535927c7691492db4b92a43b" }
vodozemac = { git = "https://github.com/matrix-org/vodozemac/", rev = "4ef989c6a8eba0bc809e285a081c56320a9bbf1e" }
wiremock = "0.6.0"
zeroize = "1.6.0"

Expand Down
2 changes: 2 additions & 0 deletions crates/matrix-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Breaking changes:

Additions:

- Expose new method `Client::Oidc::login_with_qr_code()`.
([#3466](https://github.com/matrix-org/matrix-rust-sdk/pull/3466))
- Add the `ClientBuilder::add_root_certificates()` method which re-exposes the
`reqwest::ClientBuilder::add_root_certificate()` functionality.
- 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.
Expand Down
7 changes: 6 additions & 1 deletion crates/matrix-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ uniffi = ["dep:uniffi", "matrix-sdk-base/uniffi"]

experimental-oidc = [
"ruma/unstable-msc2967",
"ruma/unstable-msc4108",
"dep:chrono",
"dep:http_old",
"dep:language-tags",
Expand Down Expand Up @@ -72,6 +73,7 @@ async-channel = "2.2.1"
async-stream = { workspace = true }
async-trait = { workspace = true }
axum = { version = "0.7.4", optional = true }
base64 = { workspace = true }
bytes = "1.1.0"
bytesize = "1.1"
chrono = { version = "0.4.23", optional = true }
Expand Down Expand Up @@ -108,9 +110,10 @@ tokio-stream = { workspace = true, features = ["sync"] }
tower = { version = "0.4.13", features = ["make"], optional = true }
tracing = { workspace = true, features = ["attributes"] }
uniffi = { workspace = true, optional = true }
url = { workspace = true }
url = { workspace = true, features = ["serde"] }
urlencoding = "2.1.3"
uuid = { version = "1.4.1", features = ["serde", "v4"], optional = true }
vodozemac = { workspace = true }
zeroize = { workspace = true }

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

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

Expand Down
6 changes: 6 additions & 0 deletions crates/matrix-sdk/src/authentication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Types and functions related to authentication in Matrix.

// TODO:(pixlwave) Move AuthenticationService from the FFI into this module.
// TODO:(poljar) Move the oidc and matrix_auth modules under this module.

use std::pin::Pin;

Expand All @@ -28,6 +31,9 @@ use crate::{
Client, RefreshTokenError, SessionChange,
};

#[cfg(all(feature = "experimental-oidc", feature = "e2e-encryption", not(target_arch = "wasm32")))]
pub mod qrcode;

/// Session tokens, for any kind of authentication.
#[allow(missing_debug_implementations, clippy::large_enum_variant)]
pub enum SessionTokens {
Expand Down
Loading

0 comments on commit e6dc24a

Please sign in to comment.