refactor(sdk): Move oidc module to authentication::oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
committed by
Damir Jelić
parent
02c2e55855
commit
3e78e441d4
@@ -5,7 +5,7 @@ use std::{
|
||||
};
|
||||
|
||||
use matrix_sdk::{
|
||||
oidc::{
|
||||
authentication::oidc::{
|
||||
registrations::OidcRegistrationsError,
|
||||
types::{
|
||||
iana::oauth::OAuthClientAuthenticationMethod,
|
||||
|
||||
@@ -7,11 +7,7 @@ use std::{
|
||||
|
||||
use anyhow::{anyhow, Context as _};
|
||||
use matrix_sdk::{
|
||||
media::{
|
||||
MediaFileHandle as SdkMediaFileHandle, MediaFormat, MediaRequestParameters,
|
||||
MediaThumbnailSettings,
|
||||
},
|
||||
oidc::{
|
||||
authentication::oidc::{
|
||||
registrations::{ClientId, OidcRegistrations},
|
||||
requests::account_management::AccountManagementActionFull,
|
||||
types::{
|
||||
@@ -23,6 +19,10 @@ use matrix_sdk::{
|
||||
},
|
||||
OidcAuthorizationData, OidcSession,
|
||||
},
|
||||
media::{
|
||||
MediaFileHandle as SdkMediaFileHandle, MediaFormat, MediaRequestParameters,
|
||||
MediaThumbnailSettings,
|
||||
},
|
||||
reqwest::StatusCode,
|
||||
ruma::{
|
||||
api::client::{
|
||||
@@ -1556,10 +1556,10 @@ impl Session {
|
||||
}
|
||||
// Build the session from the OIDC UserSession.
|
||||
AuthApi::Oidc(api) => {
|
||||
let matrix_sdk::oidc::UserSession {
|
||||
let matrix_sdk::authentication::oidc::UserSession {
|
||||
meta: matrix_sdk::SessionMeta { user_id, device_id },
|
||||
tokens:
|
||||
matrix_sdk::oidc::OidcSessionTokens {
|
||||
matrix_sdk::authentication::oidc::OidcSessionTokens {
|
||||
access_token,
|
||||
refresh_token,
|
||||
latest_id_token,
|
||||
@@ -1620,12 +1620,12 @@ impl TryFrom<Session> for AuthSession {
|
||||
.transpose()
|
||||
.context("OIDC latest_id_token is invalid.")?;
|
||||
|
||||
let user_session = matrix_sdk::oidc::UserSession {
|
||||
let user_session = matrix_sdk::authentication::oidc::UserSession {
|
||||
meta: matrix_sdk::SessionMeta {
|
||||
user_id: user_id.try_into()?,
|
||||
device_id: device_id.into(),
|
||||
},
|
||||
tokens: matrix_sdk::oidc::OidcSessionTokens {
|
||||
tokens: matrix_sdk::authentication::oidc::OidcSessionTokens {
|
||||
access_token,
|
||||
refresh_token,
|
||||
latest_id_token,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{collections::HashMap, fmt, fmt::Display};
|
||||
|
||||
use matrix_sdk::{
|
||||
encryption::CryptoStoreError, event_cache::EventCacheError, oidc::OidcError, reqwest,
|
||||
room::edit::EditError, send_queue::RoomSendQueueError, HttpError, IdParseError,
|
||||
authentication::oidc::OidcError, encryption::CryptoStoreError, event_cache::EventCacheError,
|
||||
reqwest, room::edit::EditError, send_queue::RoomSendQueueError, HttpError, IdParseError,
|
||||
NotificationSettingsError as SdkNotificationSettingsError,
|
||||
QueueWedgeError as SdkQueueWedgeError, StoreError,
|
||||
};
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
//! Types and functions related to authentication in Matrix.
|
||||
|
||||
// TODO:(pixlwave) Move AuthenticationService from the FFI into this module.
|
||||
// TODO:(poljar) Move the oidc module under this module.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -24,10 +23,12 @@ use matrix_sdk_base::SessionMeta;
|
||||
use tokio::sync::{broadcast, Mutex, OnceCell};
|
||||
|
||||
pub mod matrix;
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
pub mod oidc;
|
||||
|
||||
use self::matrix::{MatrixAuth, MatrixAuthData};
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
use crate::oidc::{self, Oidc, OidcAuthData, OidcCtx};
|
||||
use self::oidc::{Oidc, OidcAuthData, OidcCtx};
|
||||
use crate::{Client, RefreshTokenError, SessionChange};
|
||||
|
||||
#[cfg(all(feature = "experimental-oidc", feature = "e2e-encryption", not(target_arch = "wasm32")))]
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ use mas_oidc_client::{
|
||||
use url::Url;
|
||||
|
||||
use super::{OidcBackend, OidcError, RefreshedSessionTokens};
|
||||
use crate::oidc::{AuthorizationCode, OidcSessionTokens};
|
||||
use crate::authentication::oidc::{AuthorizationCode, OidcSessionTokens};
|
||||
|
||||
pub(crate) const ISSUER_URL: &str = "https://oidc.example.com/issuer";
|
||||
pub(crate) const AUTHORIZATION_URL: &str = "https://oidc.example.com/authorization";
|
||||
+1
-1
@@ -42,7 +42,7 @@ use url::Url;
|
||||
|
||||
use super::{OidcBackend, OidcError, RefreshedSessionTokens};
|
||||
use crate::{
|
||||
oidc::{rng, AuthorizationCode, OidcSessionTokens},
|
||||
authentication::oidc::{rng, AuthorizationCode, OidcSessionTokens},
|
||||
Client,
|
||||
};
|
||||
|
||||
+1
-1
@@ -264,7 +264,7 @@ mod tests {
|
||||
|
||||
use super::compute_session_hash;
|
||||
use crate::{
|
||||
oidc::{
|
||||
authentication::oidc::{
|
||||
backend::mock::{MockImpl, ISSUER_URL},
|
||||
cross_process::SessionHash,
|
||||
tests,
|
||||
+1
-1
@@ -217,11 +217,11 @@ pub use self::{
|
||||
use self::{
|
||||
backend::{server::OidcServer, OidcBackend},
|
||||
cross_process::{CrossProcessRefreshLockGuard, CrossProcessRefreshManager},
|
||||
registrations::{ClientId, OidcRegistrations},
|
||||
};
|
||||
use crate::{
|
||||
authentication::{qrcode::LoginWithQrCode, AuthData},
|
||||
client::SessionChange,
|
||||
oidc::registrations::{ClientId, OidcRegistrations},
|
||||
Client, HttpError, RefreshTokenError, Result,
|
||||
};
|
||||
|
||||
+2
-5
@@ -26,14 +26,11 @@ use wiremock::{
|
||||
|
||||
use super::{
|
||||
backend::mock::{MockImpl, AUTHORIZATION_URL, ISSUER_URL},
|
||||
registrations::{ClientId, OidcRegistrations},
|
||||
AuthorizationCode, AuthorizationError, AuthorizationResponse, Oidc, OidcError, OidcSession,
|
||||
OidcSessionTokens, RedirectUriQueryParseError, UserSession,
|
||||
};
|
||||
use crate::{
|
||||
oidc::registrations::{ClientId, OidcRegistrations},
|
||||
test_utils::test_client_builder,
|
||||
Client, Error,
|
||||
};
|
||||
use crate::{test_utils::test_client_builder, Client, Error};
|
||||
|
||||
const CLIENT_ID: &str = "test_client_id";
|
||||
const REDIRECT_URI_STRING: &str = "http://matrix.example.com/oidc/callback";
|
||||
@@ -34,7 +34,7 @@ use super::{
|
||||
SecureChannelError,
|
||||
};
|
||||
#[cfg(doc)]
|
||||
use crate::oidc::Oidc;
|
||||
use crate::authentication::oidc::Oidc;
|
||||
use crate::{
|
||||
authentication::qrcode::{
|
||||
messages::QrAuthMessage, secure_channel::EstablishedSecureChannel, QRCodeLoginError,
|
||||
|
||||
@@ -33,8 +33,8 @@ use url::Url;
|
||||
pub use vodozemac::ecies::{Error as EciesError, MessageDecodeError};
|
||||
|
||||
#[cfg(doc)]
|
||||
use crate::oidc::Oidc;
|
||||
use crate::{oidc::CrossProcessRefreshLockError, HttpError};
|
||||
use crate::authentication::oidc::Oidc;
|
||||
use crate::{authentication::oidc::CrossProcessRefreshLockError, HttpError};
|
||||
|
||||
mod login;
|
||||
mod messages;
|
||||
@@ -113,7 +113,7 @@ pub enum DeviceAuhorizationOidcError {
|
||||
/// A generic OIDC error happened while we were attempting to register the
|
||||
/// device with the OIDC provider.
|
||||
#[error(transparent)]
|
||||
Oidc(#[from] crate::oidc::OidcError),
|
||||
Oidc(#[from] crate::authentication::oidc::OidcError),
|
||||
|
||||
/// The issuer URL failed to be parsed.
|
||||
#[error(transparent)]
|
||||
|
||||
@@ -32,7 +32,7 @@ use openidconnect::{
|
||||
use vodozemac::Curve25519PublicKey;
|
||||
|
||||
use super::DeviceAuhorizationOidcError;
|
||||
use crate::{http_client::HttpClient, oidc::OidcSessionTokens};
|
||||
use crate::{authentication::oidc::OidcSessionTokens, http_client::HttpClient};
|
||||
|
||||
// Obtain the device_authorization_url from the OIDC metadata provider.
|
||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
|
||||
@@ -28,14 +28,14 @@ use tokio::sync::{broadcast, Mutex, OnceCell};
|
||||
use tracing::{debug, field::debug, instrument, Span};
|
||||
|
||||
use super::{Client, ClientInner};
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
use crate::authentication::oidc::OidcCtx;
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
use crate::crypto::{CollectStrategy, TrustRequirement};
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
use crate::encryption::EncryptionSettings;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::http_client::HttpSettings;
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
use crate::oidc::OidcCtx;
|
||||
use crate::{
|
||||
authentication::AuthCtx, client::ClientServerCapabilities, config::RequestConfig,
|
||||
error::RumaApiError, http_client::HttpClient, send_queue::SendQueueData,
|
||||
|
||||
@@ -35,7 +35,7 @@ use tracing::trace;
|
||||
|
||||
use super::super::Client;
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
use crate::oidc::OidcError;
|
||||
use crate::authentication::oidc::OidcError;
|
||||
use crate::{
|
||||
config::RequestConfig,
|
||||
error::{HttpError, HttpResult},
|
||||
|
||||
@@ -74,7 +74,7 @@ use url::Url;
|
||||
|
||||
use self::futures::SendRequest;
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
use crate::oidc::Oidc;
|
||||
use crate::authentication::oidc::Oidc;
|
||||
use crate::{
|
||||
authentication::{
|
||||
matrix::MatrixAuth, AuthCtx, AuthData, ReloadSessionCallback, SaveSessionCallback,
|
||||
|
||||
@@ -354,7 +354,7 @@ pub enum Error {
|
||||
/// An error occurred interacting with the OpenID Connect API.
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
#[error(transparent)]
|
||||
Oidc(#[from] crate::oidc::OidcError),
|
||||
Oidc(#[from] crate::authentication::oidc::OidcError),
|
||||
|
||||
/// A concurrent request to a deduplicated request has failed.
|
||||
#[error("a concurrent request failed; see logs for details")]
|
||||
@@ -561,7 +561,7 @@ pub enum RefreshTokenError {
|
||||
/// An error occurred interacting with the OpenID Connect API.
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
#[error(transparent)]
|
||||
Oidc(#[from] Arc<crate::oidc::OidcError>),
|
||||
Oidc(#[from] Arc<crate::authentication::oidc::OidcError>),
|
||||
}
|
||||
|
||||
/// Errors that can occur when manipulating push notification settings.
|
||||
|
||||
@@ -47,8 +47,6 @@ pub mod event_handler;
|
||||
mod http_client;
|
||||
pub mod media;
|
||||
pub mod notification_settings;
|
||||
#[cfg(feature = "experimental-oidc")]
|
||||
pub mod oidc;
|
||||
pub mod pusher;
|
||||
pub mod room;
|
||||
pub mod room_directory_search;
|
||||
|
||||
@@ -129,8 +129,8 @@ async fn test_reset_oidc() {
|
||||
registration::{ClientMetadata, VerifiedClientMetadata},
|
||||
};
|
||||
use matrix_sdk::{
|
||||
authentication::oidc::{OidcSession, OidcSessionTokens, UserSession},
|
||||
encryption::CrossSigningResetAuthType,
|
||||
oidc::{OidcSession, OidcSessionTokens, UserSession},
|
||||
};
|
||||
use similar_asserts::assert_eq;
|
||||
use url::Url;
|
||||
|
||||
@@ -30,9 +30,7 @@ use axum::{
|
||||
};
|
||||
use futures_util::StreamExt;
|
||||
use matrix_sdk::{
|
||||
config::SyncSettings,
|
||||
encryption::{recovery::RecoveryState, CrossSigningResetAuthType},
|
||||
oidc::{
|
||||
authentication::oidc::{
|
||||
requests::account_management::AccountManagementActionFull,
|
||||
types::{
|
||||
client_credentials::ClientCredentials,
|
||||
@@ -44,6 +42,8 @@ use matrix_sdk::{
|
||||
},
|
||||
AuthorizationCode, AuthorizationResponse, OidcAuthorizationData, OidcSession, UserSession,
|
||||
},
|
||||
config::SyncSettings,
|
||||
encryption::{recovery::RecoveryState, CrossSigningResetAuthType},
|
||||
room::Room,
|
||||
ruma::events::room::message::{MessageType, OriginalSyncRoomMessageEvent},
|
||||
Client, ClientBuildError, Result, RoomState,
|
||||
|
||||
@@ -4,12 +4,14 @@ use anyhow::{bail, Context, Result};
|
||||
use clap::Parser;
|
||||
use futures_util::StreamExt;
|
||||
use matrix_sdk::{
|
||||
authentication::qrcode::{LoginProgress, QrCodeData, QrCodeModeData},
|
||||
oidc::types::{
|
||||
iana::oauth::OAuthClientAuthenticationMethod,
|
||||
oidc::ApplicationType,
|
||||
registration::{ClientMetadata, Localized, VerifiedClientMetadata},
|
||||
requests::GrantType,
|
||||
authentication::{
|
||||
oidc::types::{
|
||||
iana::oauth::OAuthClientAuthenticationMethod,
|
||||
oidc::ApplicationType,
|
||||
registration::{ClientMetadata, Localized, VerifiedClientMetadata},
|
||||
requests::GrantType,
|
||||
},
|
||||
qrcode::{LoginProgress, QrCodeData, QrCodeModeData},
|
||||
},
|
||||
Client,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user