You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/04/08 03:54:13 UTC

(opendal) 01/01: fix(core/services/cos): Don't allow empty credential

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

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

commit 53377ca873c2928ce519ca57a939f89af1a76c47
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Mon Apr 8 11:53:46 2024 +0800

    fix(core/services/cos): Don't allow empty credential
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 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 29659cfc1c..5e13416249 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<()> {