plusplusjiajia commented on code in PR #2838:
URL: https://github.com/apache/iceberg-rust/pull/2838#discussion_r3688021572
##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -341,6 +306,32 @@ impl RestCatalogConfig {
.unwrap_or(false)
}
+ /// The configured auth scheme: explicit `rest.auth.type` or the default
+ /// `oauth2` (which behaves as no auth when neither `token` nor
+ /// `credential` is set).
+ fn auth_type(&self) -> String {
+ self.props
+ .get(REST_CATALOG_PROP_AUTH_TYPE)
+ .cloned()
+ .unwrap_or_else(|| AUTH_TYPE_OAUTH2.to_string())
+ }
+
+ /// Resolves the auth manager: a `with_auth_manager` override wins,
+ /// otherwise one is built from the `rest.auth.type` configuration.
+ pub(crate) fn resolve_auth_manager(&self) -> Result<Arc<dyn AuthManager>> {
+ if let Some(auth_manager) = &self.auth_manager {
+ return Ok(auth_manager.clone());
+ }
+ match self.auth_type().as_str() {
+ AUTH_TYPE_NONE => Ok(Arc::new(NoopAuthManager)),
+ AUTH_TYPE_OAUTH2 =>
Ok(Arc::new(OAuth2Manager::from_config(self)?)),
+ other => Err(Error::new(
+ ErrorKind::DataInvalid,
+ format!("unknown '{REST_CATALOG_PROP_AUTH_TYPE}': {other}"),
Review Comment:
@CTTY Good point — done in the latest push.
--
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]