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


##########
crates/catalog/rest/src/auth/mod.rs:
##########
@@ -115,6 +117,48 @@ pub trait AuthManager: Debug + Send + Sync {
 pub trait AuthSession: Debug + Send + Sync {
     /// Applies authentication to the request (adds headers, signs, ...).
     async fn authenticate(&self, request: &mut HttpRequest) -> Result<()>;
+
+    /// Called when the catalog answers a request this session authenticated
+    /// with `401 Unauthorized` or `419 Authentication Timeout`. `request` is
+    /// the request as it was sent.
+    ///
+    /// With [`UnauthorizedAction::Retry`], this same session authenticates the
+    /// request again and it is sent once more, so a session that replaces a
+    /// rejected credential keeps it behind interior mutability (e.g. a
+    /// `Mutex`). The answer to that second attempt is returned whatever its
+    /// status, without calling this method again. The default returns
+    /// [`UnauthorizedAction::Fail`].
+    ///
+    /// Not called for a request with a streaming body, which cannot be sent
+    /// twice.
+    ///
+    /// A session that wraps another forwards this call with the request as
+    /// the inner session authenticated it, undoing its own changes such as a
+    /// moved `Authorization` header.
+    ///
+    /// # Errors
+    ///
+    /// An error is returned to the caller in place of the response, with the
+    /// response status as its `status` context.
+    async fn on_unauthorized(

Review Comment:
   I think `fn on_unauthorized()` would fit well if we only used it on 401, but 
with 419 too, maybe a more neutral `fn on_rejected()` would fit better?
   I think the fact that `401 Unauthorized` is a misnomer (it's an 
authentication error, really) would speak for it too.
   
   ---
   
   I could also imagine naming it something like `fn invalidate()` to be more 
prescriptive about what an implementor is supposed to do with it.



-- 
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