mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-23 22:40:39 +02:00
iam: authorize IAM management actions as IAM actions (#10593)
* s3: keep a non-S3 action out of the request-shape resolver
ResolveS3Action reads the request shape before it looks at the base action, so
an iam: or sts: action on a request that happens to carry an S3 query parameter
came back as the S3 action for that parameter. An action that already names its
service is resolved; there is no S3 request shape to read for it.
* iam: authorize the standalone IAM server's actions as IAM, not as S3
The standalone `weed iam` server wrapped its single POST / route in the generic
S3 Auth middleware with ACTION_ADMIN. The route has no {bucket}, so the check
ran with an empty bucket and resolved to a coarse S3 action rather than the IAM
one. The embedded IAM surface checks iam:<Action>; the standalone one was never
updated to match.
Both now go through one authorization function, so they cannot drift apart
again. It also rejects the anonymous identity, which has no user of its own to
run a self-service action against, and reads UserName from the body only, where
the handlers read it from.
This commit is contained in:
1 parent
c2b47967bd
commit
e8020910db
7 files changed
+321
-61
No files matched your search
@@ -723,21 +723,11 @@ func (s3a *S3ApiServer) UnifiedPostHandler(w http.ResponseWriter, r *http.Reques
|
||||
// Always set identity in context when non-nil to ensure downstream handlers have access
|
||||
r = r.WithContext(recordIdentityInContext(r, identity))
|
||||
|
||||
targetUserName := r.Form.Get("UserName")
|
||||
|
||||
// Check permissions based on action type
|
||||
isSelfServiceAction := iamRequiresAdminForOthers(action)
|
||||
isActingOnSelf := targetUserName == "" || targetUserName == identity.Name
|
||||
|
||||
// Permission check is required for all actions except for self-service actions
|
||||
// performed on the user's own identity.
|
||||
if !(isSelfServiceAction && isActingOnSelf) {
|
||||
if !identity.isAdmin() {
|
||||
if s3a.iam.VerifyActionPermission(r, identity, Action("iam:"+action), "arn:aws:iam:::*", "") != s3err.ErrNone {
|
||||
s3err.WriteErrorResponse(w, r, s3err.ErrAccessDenied)
|
||||
return
|
||||
}
|
||||
}
|
||||
// UserName comes from the body only, the same place DoActions reads it
|
||||
// from, so the authorized target and the acted-on target cannot differ.
|
||||
if s3a.iam.AuthorizeIamAction(r, identity, action, r.PostForm.Get("UserName")) != s3err.ErrNone {
|
||||
s3err.WriteErrorResponse(w, r, s3err.ErrAccessDenied)
|
||||
return
|
||||
}
|
||||
|
||||
// Call Limit middleware + DoActions
|
||||
|
||||
Reference in new issue
Block a user