Skip to content

Commit 743f383

Browse files
committed
refactor!: remove permission hook and AuthManager from core path
1 parent 188cbd2 commit 743f383

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

datafusion-postgres-cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
198198

199199
let session_config = SessionConfig::new().with_information_schema(true);
200200
let session_context = SessionContext::new_with_config(session_config);
201-
let auth_manager = Arc::new(AuthManager::new());
202201

202+
let auth_manager = Arc::new(AuthManager::new());
203203
setup_session_context(&session_context, &opts, Arc::clone(&auth_manager)).await?;
204204

205205
let server_options = ServerOptions::new()
@@ -208,7 +208,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
208208
.with_tls_cert_path(opts.tls_cert)
209209
.with_tls_key_path(opts.tls_key);
210210

211-
serve(Arc::new(session_context), &server_options, auth_manager)
211+
serve(Arc::new(session_context), &server_options)
212212
.await
213213
.map_err(|e| format!("Failed to run server: {e}"))?;
214214

datafusion-postgres/src/handlers.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ use pgwire::api::{ClientInfo, ErrorHandler, PgWireServerHandlers, Type};
2222
use pgwire::error::{PgWireError, PgWireResult};
2323
use pgwire::types::format::FormatOptions;
2424

25-
use crate::auth::AuthManager;
2625
use crate::client;
27-
use crate::hooks::permissions::PermissionsHook;
2826
use crate::hooks::set_show::SetShowHook;
2927
use crate::hooks::transactions::TransactionStatementHook;
3028
use crate::hooks::QueryHook;
@@ -44,9 +42,8 @@ pub struct HandlerFactory {
4442
}
4543

4644
impl HandlerFactory {
47-
pub fn new(session_context: Arc<SessionContext>, auth_manager: Arc<AuthManager>) -> Self {
48-
let session_service =
49-
Arc::new(DfSessionService::new(session_context, auth_manager.clone()));
45+
pub fn new(session_context: Arc<SessionContext>) -> Self {
46+
let session_service = Arc::new(DfSessionService::new(session_context));
5047
HandlerFactory { session_service }
5148
}
5249

@@ -99,15 +96,9 @@ pub struct DfSessionService {
9996
}
10097

10198
impl DfSessionService {
102-
pub fn new(
103-
session_context: Arc<SessionContext>,
104-
auth_manager: Arc<AuthManager>,
105-
) -> DfSessionService {
106-
let hooks: Vec<Arc<dyn QueryHook>> = vec![
107-
Arc::new(PermissionsHook::new(auth_manager)),
108-
Arc::new(SetShowHook),
109-
Arc::new(TransactionStatementHook),
110-
];
99+
pub fn new(session_context: Arc<SessionContext>) -> DfSessionService {
100+
let hooks: Vec<Arc<dyn QueryHook>> =
101+
vec![Arc::new(SetShowHook), Arc::new(TransactionStatementHook)];
111102
Self::new_with_hooks(session_context, hooks)
112103
}
113104

datafusion-postgres/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use tokio::sync::Semaphore;
2121
use tokio_rustls::rustls::{self, ServerConfig};
2222
use tokio_rustls::TlsAcceptor;
2323

24-
use crate::auth::AuthManager;
2524
use handlers::HandlerFactory;
2625
pub use handlers::{DfSessionService, Parser};
2726
pub use hooks::QueryHook;
@@ -86,10 +85,9 @@ fn setup_tls(cert_path: &str, key_path: &str) -> Result<TlsAcceptor, IOError> {
8685
pub async fn serve(
8786
session_context: Arc<SessionContext>,
8887
opts: &ServerOptions,
89-
auth_manager: Arc<AuthManager>,
9088
) -> Result<(), std::io::Error> {
9189
// Create the handler factory with authentication
92-
let factory = Arc::new(HandlerFactory::new(session_context, auth_manager));
90+
let factory = Arc::new(HandlerFactory::new(session_context));
9391

9492
serve_with_handlers(factory, opts).await
9593
}

datafusion-postgres/src/testing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn setup_handlers() -> DfSessionService {
2121
)
2222
.expect("Failed to setup sesession context");
2323

24-
DfSessionService::new(Arc::new(session_context), Arc::new(AuthManager::new()))
24+
DfSessionService::new(Arc::new(session_context))
2525
}
2626

2727
#[derive(Debug, Default)]

0 commit comments

Comments
 (0)