feat:policy Resources support string and array modes. (#1346)

Co-authored-by: loverustfs <hello@rustfs.com>
This commit is contained in:
GatewayJ
2026-01-04 19:21:37 +08:00
committed by GitHub
parent 38c2d74d36
commit f5f6ea4a5c
4 changed files with 178 additions and 6 deletions
+4 -1
View File
@@ -167,7 +167,10 @@ impl Operation for AssumeRoleHandle {
pub fn populate_session_policy(claims: &mut HashMap<String, Value>, policy: &str) -> S3Result<()> {
if !policy.is_empty() {
let session_policy = Policy::parse_config(policy.as_bytes())
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("parse policy err {e}")))?;
.map_err(|e| {
let error_msg = format!("Failed to parse session policy: {}. Please check that the policy is valid JSON format with standard brackets [] for arrays.", e);
S3Error::with_message(S3ErrorCode::InvalidRequest, error_msg)
})?;
if session_policy.version.is_empty() {
return Err(s3_error!(InvalidRequest, "invalid policy"));
}