DerGut commented on code in PR #2838:
URL: https://github.com/apache/iceberg-rust/pull/2838#discussion_r3634014541
##########
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, AuthRequest, 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:
Carrying [my
feedback](https://github.com/apache/iceberg-rust/pull/2815#discussion_r3601701288)
from the other PR over.
I think right now having the `AuthManager` and `AuthSession` as fields of
the `HttpClient` is perfectly fine. However, we're going to need to add
additional methods to the `AuthManager` trait which complicate this:
```rust
fn table_session(_: TableIdent, parent: Arc<dyn AuthSession>) -> Arc<dyn
AuthSession>;
fn contextual_session(_: SessionContext, parent: Arc<dyn AuthSession>) ->
Arc<dyn AuthSession;
```
`table_session()` and `contextual_session()` will help us to enable
credentials vending at table-level and query-level authentication respectively.
Both take arguments that a low-level `HttpClient` should have no business in
dealing with IMO. E.g. `TableIdent` is Iceberg-specific and not HTTP-specific.
Same goes for the `SessionContext`. In that sense, I feel like the
`RestCatalog` may be a better place to host these two fields.
--
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]