Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

816 B
Raw Blame
package s3vectors

import (
	"net/http"

	"github.com/seaweedfs/seaweedfs/weed/s3api/s3tables"
)

type IAMAuthorizer interface {
	EvaluateIAMPolicy(r *http.Request, action, resource string, policyContext *s3tables.PolicyContext) (allowed, denied bool)
}

func (s *Server) checkPermission(r *http.Request, action, principal, owner, policy, resource string, ctx *s3tables.PolicyContext) bool {
	if authorizer, ok := s.authenticator.(IAMAuthorizer); ok {
		allowed, denied := authorizer.EvaluateIAMPolicy(r, action, resource, ctx)
		if denied {
			return false
		}
		if allowed {
			copyContext := *ctx
			copyContext.IdentityActions = append(append([]string{}, ctx.IdentityActions...), action)
			ctx = &copyContext
		}
	}
	return s3tables.CheckPermissionWithContext(action, principal, owner, policy, resource, ctx)
}