DerGut commented on code in PR #2815:
URL: https://github.com/apache/iceberg-rust/pull/2815#discussion_r3601701288


##########
crates/catalog/rest/src/client.rs:
##########
@@ -17,34 +17,27 @@
 
 use std::collections::HashMap;
 use std::fmt::{Debug, Formatter};
+use std::sync::Arc;
 
-use http::StatusCode;
 use iceberg::{Error, ErrorKind, Result};
 use reqwest::header::HeaderMap;
 use reqwest::{Client, IntoUrl, Method, Request, RequestBuilder, Response};
 use serde::de::DeserializeOwned;
-use tokio::sync::Mutex;
 
 use crate::RestCatalogConfig;
-use crate::types::{ErrorResponse, TokenResponse};
+use crate::auth::{AuthManager, AuthSession};
 
 pub(crate) struct HttpClient {
     client: Client,
 
-    /// The token to be used for authentication.
-    ///
-    /// It's possible to fetch the token from the server while needed.
-    token: Mutex<Option<String>>,
-    /// The token endpoint to be used for authentication.
-    token_endpoint: String,
-    /// The credential to be used for authentication.
-    credential: Option<(Option<String>, String)>,
     /// Extra headers to be added to each request.
     extra_headers: HeaderMap,
-    /// Extra oauth parameters to be added to each authentication request.
-    extra_oauth_params: HashMap<String, String>,
     /// Whether to disable header redaction in error logs (defaults to false 
for security).
     disable_header_redaction: bool,
+    /// The auth manager living for the lifetime of the catalog.
+    auth_manager: Arc<dyn AuthManager>,
+    /// The session authenticating requests in the current phase.
+    session: Arc<dyn AuthSession>,

Review Comment:
   I'm thinking that the `AuthManager`/ `AuthSession` might be better placed in 
the RestCatalog.
   
   In this current implementation both are working fine, but if we add 
`table_session()` and `contextual_session()` to the mix, the `AuthManager` will 
have to translate `TableIdent`s and `SessionContext`s to `AuthSession`s.
   IMO this is not the layer of abstraction that the `HttpClient` should 
operate on. In my mind, an AuthManager manages the creation of `AuthSession`s 
which the client can then use to authenticate its requests. The client should 
therefore not itself have to deal with creating those sessions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to