diff --git a/io/zenoh-link-commons/src/unicast.rs b/io/zenoh-link-commons/src/unicast.rs index 3b86eebb54..cd8c550503 100644 --- a/io/zenoh-link-commons/src/unicast.rs +++ b/io/zenoh-link-commons/src/unicast.rs @@ -17,15 +17,16 @@ use core::{ hash::{Hash, Hasher}, ops::Deref, }; -use serde::Serialize; use std::net::SocketAddr; use async_trait::async_trait; +use serde::Serialize; use zenoh_protocol::{ core::{EndPoint, Locator}, transport::BatchSize, }; use zenoh_result::ZResult; + pub type LinkManagerUnicast = Arc; #[async_trait] pub trait LinkManagerUnicastTrait: Send + Sync { diff --git a/io/zenoh-links/zenoh-link-tls/src/unicast.rs b/io/zenoh-links/zenoh-link-tls/src/unicast.rs index 50444c6d25..2e40f23dae 100644 --- a/io/zenoh-links/zenoh-link-tls/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-tls/src/unicast.rs @@ -24,8 +24,6 @@ use tokio_util::sync::CancellationToken; //use webpki::anchor_from_trusted_cert; use x509_parser::prelude::*; use zenoh_core::zasynclock; -//use zenoh_link_commons::tls::WebPkiVerifierAnyServerName; - use zenoh_link_commons::{ get_ip_interface_names, LinkAuthId, LinkAuthIdBuilder, LinkAuthType, LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, ListenersUnicastIP, NewLinkChannelSender, diff --git a/io/zenoh-links/zenoh-link-vsock/src/unicast.rs b/io/zenoh-links/zenoh-link-vsock/src/unicast.rs index c199cbd077..32b292ca7e 100644 --- a/io/zenoh-links/zenoh-link-vsock/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-vsock/src/unicast.rs @@ -27,9 +27,8 @@ use tokio_vsock::{ VMADDR_CID_LOCAL, }; use zenoh_core::{zasyncread, zasyncwrite}; -use zenoh_link_commons::LinkAuthId; use zenoh_link_commons::{ - LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, NewLinkChannelSender, + LinkAuthId, LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, NewLinkChannelSender, }; use zenoh_protocol::{ core::{endpoint::Address, EndPoint, Locator}, diff --git a/io/zenoh-links/zenoh-link-ws/src/unicast.rs b/io/zenoh-links/zenoh-link-ws/src/unicast.rs index d22d2c3d75..336e8af975 100644 --- a/io/zenoh-links/zenoh-link-ws/src/unicast.rs +++ b/io/zenoh-links/zenoh-link-ws/src/unicast.rs @@ -33,9 +33,8 @@ use tokio::{ use tokio_tungstenite::{accept_async, tungstenite::Message, MaybeTlsStream, WebSocketStream}; use tokio_util::sync::CancellationToken; use zenoh_core::{zasynclock, zasyncread, zasyncwrite}; -use zenoh_link_commons::LinkAuthId; use zenoh_link_commons::{ - LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, NewLinkChannelSender, + LinkAuthId, LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, NewLinkChannelSender, }; use zenoh_protocol::{ core::{EndPoint, Locator}, diff --git a/io/zenoh-transport/src/unicast/authentication.rs b/io/zenoh-transport/src/unicast/authentication.rs index c0bfa1b17b..b66289983e 100644 --- a/io/zenoh-transport/src/unicast/authentication.rs +++ b/io/zenoh-transport/src/unicast/authentication.rs @@ -1,6 +1,7 @@ +use zenoh_link::{LinkAuthId, LinkAuthType}; + #[cfg(feature = "auth_usrpwd")] use super::establishment::ext::auth::UsrPwdId; -use zenoh_link::{LinkAuthId, LinkAuthType}; #[derive(Clone, Debug, PartialEq, Eq)] pub enum AuthId { @@ -8,6 +9,7 @@ pub enum AuthId { Username(String), None, } + impl From for AuthId { fn from(lid: LinkAuthId) -> Self { match (lid.get_type(), lid.get_value()) { @@ -18,6 +20,7 @@ impl From for AuthId { } } } + #[cfg(feature = "auth_usrpwd")] impl From for AuthId { fn from(user_password_id: UsrPwdId) -> Self { diff --git a/io/zenoh-transport/src/unicast/establishment/accept.rs b/io/zenoh-transport/src/unicast/establishment/accept.rs index 5445e2c669..9a7151252d 100644 --- a/io/zenoh-transport/src/unicast/establishment/accept.rs +++ b/io/zenoh-transport/src/unicast/establishment/accept.rs @@ -11,9 +11,8 @@ // Contributors: // ZettaScale Zenoh Team, // -#[cfg(feature = "auth_usrpwd")] -use super::ext::auth::UsrPwdId; use std::time::Duration; + use async_trait::async_trait; use rand::Rng; use tokio::sync::Mutex; @@ -32,6 +31,8 @@ use zenoh_protocol::{ }; use zenoh_result::ZResult; +#[cfg(feature = "auth_usrpwd")] +use super::ext::auth::UsrPwdId; #[cfg(feature = "shared-memory")] use super::ext::shm::AuthSegment; #[cfg(feature = "shared-memory")] diff --git a/io/zenoh-transport/src/unicast/establishment/open.rs b/io/zenoh-transport/src/unicast/establishment/open.rs index ac541e4825..2d50d465bf 100644 --- a/io/zenoh-transport/src/unicast/establishment/open.rs +++ b/io/zenoh-transport/src/unicast/establishment/open.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "auth_usrpwd")] -use crate::unicast::establishment::ext::auth::UsrPwdId; // // Copyright (c) 2022 ZettaScale Technology // @@ -34,6 +32,8 @@ use zenoh_result::ZResult; use super::ext::shm::AuthSegment; #[cfg(feature = "shared-memory")] use crate::shm::TransportShmConfig; +#[cfg(feature = "auth_usrpwd")] +use crate::unicast::establishment::ext::auth::UsrPwdId; use crate::{ common::batch::BatchConfig, unicast::{ diff --git a/io/zenoh-transport/src/unicast/lowlatency/transport.rs b/io/zenoh-transport/src/unicast/lowlatency/transport.rs index 58880cd6b3..abffb665b7 100644 --- a/io/zenoh-transport/src/unicast/lowlatency/transport.rs +++ b/io/zenoh-transport/src/unicast/lowlatency/transport.rs @@ -11,7 +11,6 @@ // Contributors: // ZettaScale Zenoh Team, // -use super::super::authentication::AuthId; use std::{ sync::{Arc, RwLock as SyncRwLock}, time::Duration, @@ -33,6 +32,7 @@ use zenoh_result::{zerror, ZResult}; use crate::stats::TransportStats; use crate::{ unicast::{ + authentication::AuthId, link::{LinkUnicastWithOpenAck, TransportLinkUnicast}, transport_unicast_inner::{AddLinkResult, TransportUnicastTrait}, TransportConfigUnicast, diff --git a/io/zenoh-transport/src/unicast/mod.rs b/io/zenoh-transport/src/unicast/mod.rs index 64bdd3c510..973d0bf09a 100644 --- a/io/zenoh-transport/src/unicast/mod.rs +++ b/io/zenoh-transport/src/unicast/mod.rs @@ -26,10 +26,6 @@ use std::{ sync::{Arc, Weak}, }; -use self::authentication::AuthId; -#[cfg(feature = "auth_usrpwd")] -use self::establishment::ext::auth::UsrPwdId; - #[cfg(feature = "transport_multilink")] use establishment::ext::auth::ZPublicKey; pub use manager::*; @@ -46,6 +42,9 @@ use self::transport_unicast_inner::TransportUnicastTrait; use super::{TransportPeer, TransportPeerEventHandler}; #[cfg(feature = "shared-memory")] use crate::shm::TransportShmConfig; +use crate::unicast::authentication::AuthId; +#[cfg(feature = "auth_usrpwd")] +use crate::unicast::establishment::ext::auth::UsrPwdId; /*************************************/ /* TRANSPORT UNICAST */ diff --git a/io/zenoh-transport/src/unicast/universal/transport.rs b/io/zenoh-transport/src/unicast/universal/transport.rs index bbb5c0ce7c..e7b0d52458 100644 --- a/io/zenoh-transport/src/unicast/universal/transport.rs +++ b/io/zenoh-transport/src/unicast/universal/transport.rs @@ -11,7 +11,6 @@ // Contributors: // ZettaScale Zenoh Team, // -use super::super::authentication::AuthId; use std::{ fmt::DebugStruct, sync::{Arc, RwLock}, @@ -29,6 +28,7 @@ use zenoh_protocol::{ }; use zenoh_result::{bail, zerror, ZResult}; +use super::super::authentication::AuthId; #[cfg(feature = "stats")] use crate::stats::TransportStats; use crate::{ diff --git a/zenoh/src/net/routing/interceptor/access_control.rs b/zenoh/src/net/routing/interceptor/access_control.rs index 49b97d1b83..885752e2c6 100644 --- a/zenoh/src/net/routing/interceptor/access_control.rs +++ b/zenoh/src/net/routing/interceptor/access_control.rs @@ -25,10 +25,11 @@ use zenoh_protocol::{ network::{Declare, DeclareBody, NetworkBody, NetworkMessage, Push, Request}, zenoh::{PushBody, RequestBody}, }; -use zenoh_transport::unicast::authentication::AuthId; - use zenoh_result::ZResult; -use zenoh_transport::{multicast::TransportMulticast, unicast::TransportUnicast}; +use zenoh_transport::{ + multicast::TransportMulticast, + unicast::{authentication::AuthId, TransportUnicast}, +}; use super::{ authorization::PolicyEnforcer, EgressInterceptor, IngressInterceptor, InterceptorFactory, diff --git a/zenoh/tests/authentication.rs b/zenoh/tests/authentication.rs index 8357b09495..e6995ecaa0 100644 --- a/zenoh/tests/authentication.rs +++ b/zenoh/tests/authentication.rs @@ -12,15 +12,17 @@ // ZettaScale Zenoh Team, // mod test { - use std::sync::{Arc, Mutex}; - use std::time::Duration; + use std::{ + fs, + path::Path, + sync::{Arc, Mutex}, + time::Duration, + }; + use tokio::runtime::Handle; use zenoh::prelude::*; use zenoh_core::{zlock, ztimeout}; - use std::fs; - use std::path::Path; - const TIMEOUT: Duration = Duration::from_secs(60); const SLEEP: Duration = Duration::from_secs(1); const KEY_EXPR: &str = "test/demo";