Skip to content

Commit ec8b1cd

Browse files
committed
feat(auth): get rid of the cargo feature flag for OIDC
OIDC authentication has been used in production in multiple embeddings of the Matrix Rust SDK, some of them for months already, and they're considered stable for everyday use. As such, the feature is not considered experimental anymore, especially since the future of authentication will rely on OIDC and related mechanisms.
1 parent ce44c6e commit ec8b1cd

File tree

15 files changed

+31
-82
lines changed

15 files changed

+31
-82
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
fail-fast: true
3636
matrix:
3737
name:
38-
- experimental-oidc
3938
- no-encryption
4039
- no-sqlite
4140
- no-encryption-and-sqlite

bindings/matrix-sdk-ffi/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ workspace = true
5555
features = [
5656
"anyhow",
5757
"e2e-encryption",
58-
"experimental-oidc",
5958
"experimental-widgets",
6059
"markdown",
6160
"rustls-tls", # note: differ from block below
@@ -69,7 +68,6 @@ workspace = true
6968
features = [
7069
"anyhow",
7170
"e2e-encryption",
72-
"experimental-oidc",
7371
"experimental-widgets",
7472
"markdown",
7573
"native-tls", # note: differ from block above

crates/matrix-sdk/Cargo.toml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,11 @@ markdown = ["ruma/markdown"]
4040
native-tls = ["reqwest/native-tls"]
4141
rustls-tls = ["reqwest/rustls-tls"]
4242
socks = ["reqwest/socks"]
43-
sso-login = ["dep:axum", "dep:rand", "dep:tower"]
43+
sso-login = ["dep:axum"]
4444

4545
uniffi = ["dep:uniffi", "matrix-sdk-base/uniffi", "dep:matrix-sdk-ffi-macros"]
4646

47-
experimental-oidc = [
48-
"ruma/unstable-msc2967",
49-
"ruma/unstable-msc4108",
50-
"dep:chrono",
51-
"dep:language-tags",
52-
"dep:mas-oidc-client",
53-
"dep:rand",
54-
"dep:sha2",
55-
"dep:tower",
56-
"dep:openidconnect",
57-
]
58-
experimental-widgets = ["dep:language-tags", "dep:uuid"]
47+
experimental-widgets = ["dep:uuid"]
5948

6049
docsrs = ["e2e-encryption", "sqlite", "indexeddb", "sso-login", "qrcode"]
6150

@@ -71,7 +60,7 @@ async-trait = { workspace = true }
7160
axum = { version = "0.8.1", optional = true }
7261
bytes = "1.9.0"
7362
bytesize = "1.3.0"
74-
chrono = { workspace = true, optional = true }
63+
chrono = { workspace = true }
7564
event-listener = "5.4.0"
7665
eyeball = { workspace = true }
7766
eyeball-im = { workspace = true }
@@ -83,8 +72,8 @@ http = { workspace = true }
8372
imbl = { workspace = true, features = ["serde"] }
8473
indexmap = { workspace = true }
8574
js_int = "0.2.2"
86-
language-tags = { version = "0.3.2", optional = true }
87-
mas-oidc-client = { version = "0.11.0", default-features = false, optional = true }
75+
language-tags = { version = "0.3.2" }
76+
mas-oidc-client = { version = "0.11.0", default-features = false }
8877
matrix-sdk-base = { workspace = true }
8978
matrix-sdk-common = { workspace = true }
9079
matrix-sdk-ffi-macros = { workspace = true, optional = true }
@@ -96,24 +85,26 @@ mime2ext = "0.1.53"
9685
once_cell = { workspace = true }
9786
percent-encoding = "2.3.1"
9887
pin-project-lite = { workspace = true }
99-
rand = { workspace = true , optional = true }
88+
rand = { workspace = true }
10089
ruma = { workspace = true, features = [
10190
"rand",
10291
"unstable-msc2448",
10392
"unstable-msc2965",
93+
"unstable-msc2967",
10494
"unstable-msc3930",
10595
"unstable-msc3245-v1-compat",
10696
"unstable-msc2867",
97+
"unstable-msc4108",
10798
"unstable-msc4230",
10899
] }
109100
serde = { workspace = true }
110101
serde_html_form = { workspace = true }
111102
serde_json = { workspace = true }
112-
sha2 = { workspace = true, optional = true }
103+
sha2 = { workspace = true }
113104
tempfile = { workspace = true }
114105
thiserror = { workspace = true }
115106
tokio-stream = { workspace = true, features = ["sync"] }
116-
tower = { version = "0.5.2", features = ["util"], optional = true }
107+
tower = { version = "0.5.2", features = ["util"] }
117108
tracing = { workspace = true, features = ["attributes"] }
118109
uniffi = { workspace = true, optional = true }
119110
url = { workspace = true, features = ["serde"] }
@@ -129,7 +120,7 @@ tokio = { workspace = true, features = ["macros"] }
129120

130121
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
131122
backoff = { version = "0.4.0", features = ["tokio"] }
132-
openidconnect = { version = "4.0.0", optional = true }
123+
openidconnect = { version = "4.0.0" }
133124
# only activate reqwest's stream feature on non-wasm, the wasm part seems to not
134125
# support *sending* streams, which makes it useless for us.
135126
reqwest = { workspace = true, features = ["stream", "gzip", "http2"] }

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,22 @@ use matrix_sdk_base::SessionMeta;
2121
use tokio::sync::{broadcast, Mutex, OnceCell};
2222

2323
pub mod matrix;
24-
#[cfg(feature = "experimental-oidc")]
2524
pub mod oidc;
2625

27-
use self::matrix::{MatrixAuth, MatrixAuthData};
28-
#[cfg(feature = "experimental-oidc")]
29-
use self::oidc::{Oidc, OidcAuthData, OidcCtx};
26+
use self::{
27+
matrix::{MatrixAuth, MatrixAuthData},
28+
oidc::{Oidc, OidcAuthData, OidcCtx},
29+
};
3030
use crate::{Client, RefreshTokenError, SessionChange};
3131

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

3535
/// Session tokens, for any kind of authentication.
3636
#[allow(missing_debug_implementations, clippy::large_enum_variant)]
3737
pub enum SessionTokens {
3838
/// Tokens for a [`matrix`] session.
3939
Matrix(matrix::MatrixSessionTokens),
40-
#[cfg(feature = "experimental-oidc")]
4140
/// Tokens for an [`oidc`] session.
4241
Oidc(oidc::OidcSessionTokens),
4342
}
@@ -51,7 +50,6 @@ pub(crate) type ReloadSessionCallback =
5150
/// All the data relative to authentication, and that must be shared between a
5251
/// client and all its children.
5352
pub(crate) struct AuthCtx {
54-
#[cfg(feature = "experimental-oidc")]
5553
pub(crate) oidc: OidcCtx,
5654

5755
/// Whether to try to refresh the access token automatically when an
@@ -93,7 +91,6 @@ pub enum AuthApi {
9391
Matrix(MatrixAuth),
9492

9593
/// The OpenID Connect API.
96-
#[cfg(feature = "experimental-oidc")]
9794
Oidc(Oidc),
9895
}
9996

@@ -105,7 +102,6 @@ pub enum AuthSession {
105102
Matrix(matrix::MatrixSession),
106103

107104
/// A session using the OpenID Connect API.
108-
#[cfg(feature = "experimental-oidc")]
109105
Oidc(Box<oidc::OidcSession>),
110106
}
111107

@@ -114,7 +110,6 @@ impl AuthSession {
114110
pub fn meta(&self) -> &SessionMeta {
115111
match self {
116112
AuthSession::Matrix(session) => &session.meta,
117-
#[cfg(feature = "experimental-oidc")]
118113
AuthSession::Oidc(session) => &session.user.meta,
119114
}
120115
}
@@ -123,7 +118,6 @@ impl AuthSession {
123118
pub fn into_meta(self) -> SessionMeta {
124119
match self {
125120
AuthSession::Matrix(session) => session.meta,
126-
#[cfg(feature = "experimental-oidc")]
127121
AuthSession::Oidc(session) => session.user.meta,
128122
}
129123
}
@@ -132,7 +126,6 @@ impl AuthSession {
132126
pub fn access_token(&self) -> &str {
133127
match self {
134128
AuthSession::Matrix(session) => &session.tokens.access_token,
135-
#[cfg(feature = "experimental-oidc")]
136129
AuthSession::Oidc(session) => &session.user.tokens.access_token,
137130
}
138131
}
@@ -141,7 +134,6 @@ impl AuthSession {
141134
pub fn get_refresh_token(&self) -> Option<&str> {
142135
match self {
143136
AuthSession::Matrix(session) => session.tokens.refresh_token.as_deref(),
144-
#[cfg(feature = "experimental-oidc")]
145137
AuthSession::Oidc(session) => session.user.tokens.refresh_token.as_deref(),
146138
}
147139
}
@@ -153,7 +145,6 @@ impl From<matrix::MatrixSession> for AuthSession {
153145
}
154146
}
155147

156-
#[cfg(feature = "experimental-oidc")]
157148
impl From<oidc::OidcSession> for AuthSession {
158149
fn from(session: oidc::OidcSession) -> Self {
159150
Self::Oidc(session.into())
@@ -166,7 +157,6 @@ pub(crate) enum AuthData {
166157
/// Data for the native Matrix authentication API.
167158
Matrix(MatrixAuthData),
168159
/// Data for the OpenID Connect API.
169-
#[cfg(feature = "experimental-oidc")]
170160
Oidc(OidcAuthData),
171161
}
172162

@@ -178,7 +168,6 @@ impl AuthData {
178168
pub(crate) fn access_token(&self) -> Option<String> {
179169
let token = match self {
180170
Self::Matrix(d) => d.tokens.get().access_token,
181-
#[cfg(feature = "experimental-oidc")]
182171
Self::Oidc(d) => d.tokens.get()?.get().access_token,
183172
};
184173

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@
2727
//! limited to the Authorization Code flow. It also uses some OAuth 2.0
2828
//! extensions.
2929
//!
30-
//! # Setup
31-
//!
32-
//! To enable support for OpenID Connect on the [`Client`], simply enable the
33-
//! `experimental-oidc` cargo feature for the `matrix-sdk` crate. Then this
34-
//! authentication API is available with [`Client::oidc()`].
30+
//! Support for OpenID Connect on the [`Client`] is always enabled by default
31+
//! for the `matrix-sdk` crate. Its main API object can be obtained through the
32+
//! authentication API available with [`Client::oidc()`].
3533
//!
3634
//! # Homeserver support
3735
//!

crates/matrix-sdk/src/client/builder/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@ use tokio::sync::{broadcast, Mutex, OnceCell};
2828
use tracing::{debug, field::debug, instrument, Span};
2929

3030
use super::{Client, ClientInner};
31-
#[cfg(feature = "experimental-oidc")]
32-
use crate::authentication::oidc::OidcCtx;
3331
#[cfg(feature = "e2e-encryption")]
3432
use crate::crypto::{CollectStrategy, TrustRequirement};
3533
#[cfg(feature = "e2e-encryption")]
3634
use crate::encryption::EncryptionSettings;
3735
#[cfg(not(target_arch = "wasm32"))]
3836
use crate::http_client::HttpSettings;
3937
use crate::{
40-
authentication::AuthCtx, client::ClientServerCapabilities, config::RequestConfig,
41-
error::RumaApiError, http_client::HttpClient, send_queue::SendQueueData,
42-
sliding_sync::VersionBuilder as SlidingSyncVersionBuilder, HttpError, IdParseError,
38+
authentication::{oidc::OidcCtx, AuthCtx},
39+
client::ClientServerCapabilities,
40+
config::RequestConfig,
41+
error::RumaApiError,
42+
http_client::HttpClient,
43+
send_queue::SendQueueData,
44+
sliding_sync::VersionBuilder as SlidingSyncVersionBuilder,
45+
HttpError, IdParseError,
4346
};
4447

4548
/// Builder that allows creating and configuring various parts of a [`Client`].
@@ -510,7 +513,6 @@ impl ClientBuilder {
510513
version
511514
};
512515

513-
#[cfg(feature = "experimental-oidc")]
514516
let allow_insecure_oidc = homeserver.scheme() == "http";
515517

516518
let auth_ctx = Arc::new(AuthCtx {
@@ -520,7 +522,6 @@ impl ClientBuilder {
520522
auth_data: OnceCell::default(),
521523
reload_session_callback: OnceCell::default(),
522524
save_session_callback: OnceCell::default(),
523-
#[cfg(feature = "experimental-oidc")]
524525
oidc: OidcCtx::new(allow_insecure_oidc),
525526
});
526527

crates/matrix-sdk/src/client/futures.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use std::{fmt::Debug, future::IntoFuture};
1919
use eyeball::SharedObservable;
2020
#[cfg(not(target_arch = "wasm32"))]
2121
use eyeball::Subscriber;
22-
#[cfg(feature = "experimental-oidc")]
2322
use mas_oidc_client::{
2423
error::{
2524
Error as OidcClientError, ErrorBody as OidcErrorBody, HttpError as OidcHttpError,
@@ -29,14 +28,11 @@ use mas_oidc_client::{
2928
};
3029
use matrix_sdk_common::boxed_into_future;
3130
use ruma::api::{client::error::ErrorKind, error::FromHttpResponseError, OutgoingRequest};
32-
#[cfg(feature = "experimental-oidc")]
33-
use tracing::error;
34-
use tracing::trace;
31+
use tracing::{error, trace};
3532

3633
use super::super::Client;
37-
#[cfg(feature = "experimental-oidc")]
38-
use crate::authentication::oidc::OidcError;
3934
use crate::{
35+
authentication::oidc::OidcError,
4036
config::RequestConfig,
4137
error::{HttpError, HttpResult},
4238
RefreshTokenError, TransmissionProgress,
@@ -134,7 +130,6 @@ where
134130
client.broadcast_unknown_token(soft_logout);
135131
}
136132

137-
#[cfg(feature = "experimental-oidc")]
138133
RefreshTokenError::Oidc(oidc_error) => {
139134
match **oidc_error {
140135
OidcError::Oidc(OidcClientError::TokenRefresh(

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ use tracing::{debug, error, instrument, trace, warn, Instrument, Span};
7373
use url::Url;
7474

7575
use self::futures::SendRequest;
76-
#[cfg(feature = "experimental-oidc")]
77-
use crate::authentication::oidc::Oidc;
7876
use crate::{
7977
authentication::{
80-
matrix::MatrixAuth, AuthCtx, AuthData, ReloadSessionCallback, SaveSessionCallback,
78+
matrix::MatrixAuth, oidc::Oidc, AuthCtx, AuthData, ReloadSessionCallback,
79+
SaveSessionCallback,
8180
},
8281
config::RequestConfig,
8382
deduplicating_handler::DeduplicatingHandler,
@@ -583,7 +582,6 @@ impl Client {
583582
pub fn auth_api(&self) -> Option<AuthApi> {
584583
match self.inner.auth_ctx.auth_data.get()? {
585584
AuthData::Matrix(_) => Some(AuthApi::Matrix(self.matrix_auth())),
586-
#[cfg(feature = "experimental-oidc")]
587585
AuthData::Oidc(_) => Some(AuthApi::Oidc(self.oidc())),
588586
}
589587
}
@@ -597,7 +595,6 @@ impl Client {
597595
pub fn session(&self) -> Option<AuthSession> {
598596
match self.auth_api()? {
599597
AuthApi::Matrix(api) => api.session().map(Into::into),
600-
#[cfg(feature = "experimental-oidc")]
601598
AuthApi::Oidc(api) => api.full_session().map(Into::into),
602599
}
603600
}
@@ -639,7 +636,6 @@ impl Client {
639636
}
640637

641638
/// Access the OpenID Connect API of the client.
642-
#[cfg(feature = "experimental-oidc")]
643639
pub fn oidc(&self) -> Oidc {
644640
Oidc::new(self.clone())
645641
}
@@ -1250,7 +1246,6 @@ impl Client {
12501246
let session = session.into();
12511247
match session {
12521248
AuthSession::Matrix(s) => Box::pin(self.matrix_auth().restore_session(s)).await,
1253-
#[cfg(feature = "experimental-oidc")]
12541249
AuthSession::Oidc(s) => Box::pin(self.oidc().restore_session(*s)).await,
12551250
}
12561251
}
@@ -1286,7 +1281,6 @@ impl Client {
12861281
trace!("Token refresh: Using the homeserver.");
12871282
Box::pin(api.refresh_access_token()).await?;
12881283
}
1289-
#[cfg(feature = "experimental-oidc")]
12901284
AuthApi::Oidc(api) => {
12911285
trace!("Token refresh: Using OIDC.");
12921286
Box::pin(api.refresh_access_token()).await?;

0 commit comments

Comments
 (0)