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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
IAM: add support for advanced IAM config file to server command (#7317)
Nial20e0d91037de
diff --git a/weed/command/server.go b/weed/command/server.goindex 8f7267d3eb..f2e2e1b58d 100644--- a/weed/command/server.go+++ b/weed/command/server.go@@ -63,6 +63,7 @@ var (serverRack = cmdServer.Flag.String("rack", "", "current volume server's rack name")serverWhiteListOption = cmdServer.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")serverDisableHttp = cmdServer.Flag.Bool("disableHttp", false, "disable http requests, only gRPC operations are allowed.")+ serverIamConfig = cmdServer.Flag.String("iam.config", "", "path to the advanced IAM config file for S3. An alias for -s3.iam.config, but with lower priority.")volumeDataFolders = cmdServer.Flag.String("dir", os.TempDir(), "directories to store data files. dir[,dir]...")volumeMaxDataVolumeCounts = cmdServer.Flag.String("volume.max", "8", "maximum numbers of volumes, count[,count]... If set to zero, the limit will be auto configured as free disk space divided by volume size.")volumeMinFreeSpacePercent = cmdServer.Flag.String("volume.minFreeSpacePercent", "1", "minimum free disk space (default to 1%). Low disk space will mark all volumes as ReadOnly (deprecated, use minFreeSpace instead).")@@ -160,6 +161,7 @@ func init() {s3Options.tlsCACertificate = cmdServer.Flag.String("s3.cacert.file", "", "path to the TLS CA certificate file")s3Options.tlsVerifyClientCert = cmdServer.Flag.Bool("s3.tlsVerifyClientCert", false, "whether to verify the client's certificate")s3Options.config = cmdServer.Flag.String("s3.config", "", "path to the config file")+ s3Options.iamConfig = cmdServer.Flag.String("s3.iam.config", "", "path to the advanced IAM config file for S3. Overrides -iam.config if both are provided.")s3Options.auditLogConfig = cmdServer.Flag.String("s3.auditLogConfig", "", "path to the audit log config file")s3Options.allowEmptyFolder = cmdServer.Flag.Bool("s3.allowEmptyFolder", true, "allow empty folders")s3Options.allowDeleteBucketNotEmpty = cmdServer.Flag.Bool("s3.allowDeleteBucketNotEmpty", true, "allow recursive deleting all entries along with bucket")@@ -321,6 +323,12 @@ func runServer(cmd *Command, args []string) bool {}if *isStartingS3 {+ // Handle IAM config: -s3.iam.config takes precedence over -iam.config+ if *s3Options.iamConfig == "" {+ *s3Options.iamConfig = *serverIamConfig+ } else if *serverIamConfig != "" && *s3Options.iamConfig != *serverIamConfig {+ glog.V(0).Infof("both -s3.iam.config(%s) and -iam.config(%s) provided; using -s3.iam.config", *s3Options.iamConfig, *serverIamConfig)+ }go func() {time.Sleep(2 * time.Second)s3Options.localFilerSocket = filerOptions.localSocketdiff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.goindex 5af2749707..e21886c579 100644--- a/weed/s3api/s3api_server.go+++ b/weed/s3api/s3api_server.go@@ -473,12 +473,23 @@ func loadIAMManagerFromConfig(configPath string, filerAddressProvider func() strreturn nil, fmt.Errorf("failed to parse config: %w", err)}+ // Ensure a valid policy engine config exists+ if configRoot.Policy == nil {+ // Provide a secure default if not specified in the config file+ // Default to Deny with in-memory store so that JSON-defined policies work without filer+ glog.V(0).Infof("No policy engine config provided; using defaults (DefaultEffect=%s, StoreType=%s)", sts.EffectDeny, sts.StoreTypeMemory)+ configRoot.Policy = &policy.PolicyEngineConfig{+ DefaultEffect: sts.EffectDeny,+ StoreType: sts.StoreTypeMemory,+ }+ }+// Create IAM configurationiamConfig := &integration.IAMConfig{STS: configRoot.STS,Policy: configRoot.Policy,Roles: &integration.RoleStoreConfig{- StoreType: "memory", // Use memory store for JSON config-based setup+ StoreType: sts.StoreTypeMemory, // Use memory store for JSON config-based setup},}