This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 4e5beb9374 fix(core/services/cos): Don't allow empty credential (#4457)
4e5beb9374 is described below

commit 4e5beb9374b77e9574d64e0da6106f5122014059
Author: Xuanwo <[email protected]>
AuthorDate: Wed Apr 10 11:32:20 2024 +0800

    fix(core/services/cos): Don't allow empty credential (#4457)
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/services/cos/core.rs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/core/src/services/cos/core.rs b/core/src/services/cos/core.rs
index 220433f7c9..3a0a9000d7 100644
--- a/core/src/services/cos/core.rs
+++ b/core/src/services/cos/core.rs
@@ -66,10 +66,13 @@ impl CosCore {
             .map_err(new_request_credential_error)?;
 
         if let Some(cred) = cred {
-            Ok(Some(cred))
-        } else {
-            Ok(None)
+            return Ok(Some(cred));
         }
+
+        Err(Error::new(
+            ErrorKind::PermissionDenied,
+            "no valid credential found and anonymous access is not allowed",
+        ))
     }
 
     pub async fn sign<T>(&self, req: &mut Request<T>) -> Result<()> {

Reply via email to