mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-19 05:36:58 +00:00
Fix IAM manager and post policy to use current active filer
This commit is contained in:
@@ -38,16 +38,6 @@ type IamS3ApiConfigure struct {
|
||||
credentialManager *credential.CredentialManager
|
||||
}
|
||||
|
||||
// getFilerAddress returns the current filer address to use
|
||||
// Note: IAM operations don't have access to FilerClient's current filer tracking
|
||||
// Returns the first filer as fallback - consider adding FilerClient to IamS3ApiConfigure
|
||||
func (iama *IamS3ApiConfigure) getFilerAddress() pb.ServerAddress {
|
||||
if len(iama.option.Filers) > 0 {
|
||||
return iama.option.Filers[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type IamServerOption struct {
|
||||
Masters map[string]pb.ServerAddress
|
||||
Filers []pb.ServerAddress
|
||||
|
||||
@@ -114,7 +114,7 @@ func (s3a *S3ApiServer) PostPolicyBucketHandler(w http.ResponseWriter, r *http.R
|
||||
}
|
||||
}
|
||||
|
||||
uploadUrl := fmt.Sprintf("http://%s%s/%s%s", s3a.getFilerAddress().ToHttpAddress(), s3a.option.BucketsPath, bucket, urlEscapeObject(object))
|
||||
filePath := fmt.Sprintf("%s/%s%s", s3a.option.BucketsPath, bucket, object)
|
||||
|
||||
// Get ContentType from post formData
|
||||
// Otherwise from formFile ContentType
|
||||
@@ -136,7 +136,7 @@ func (s3a *S3ApiServer) PostPolicyBucketHandler(w http.ResponseWriter, r *http.R
|
||||
}
|
||||
}
|
||||
|
||||
etag, errCode, sseMetadata := s3a.putToFiler(r, uploadUrl, fileBody, bucket, 1)
|
||||
etag, errCode, sseMetadata := s3a.putToFiler(r, filePath, fileBody, bucket, 1)
|
||||
|
||||
if errCode != s3err.ErrNone {
|
||||
s3err.WriteErrorResponse(w, r, errCode)
|
||||
|
||||
@@ -154,22 +154,16 @@ func NewS3ApiServerWithStore(router *mux.Router, option *S3ApiServerOption, expl
|
||||
if option.IamConfig != "" {
|
||||
glog.V(1).Infof("Loading advanced IAM configuration from: %s", option.IamConfig)
|
||||
|
||||
// Note: IAM manager and S3IAMIntegration currently use only the first filer address
|
||||
// TODO: Update loadIAMManagerFromConfig and NewS3IAMIntegration to support multiple filers
|
||||
// for full HA. This is a known limitation for filer-backed IAM stores.
|
||||
filerAddr := ""
|
||||
if len(option.Filers) > 0 {
|
||||
filerAddr = string(option.Filers[0])
|
||||
}
|
||||
|
||||
// Use FilerClient's GetCurrentFiler for HA-aware filer selection
|
||||
iamManager, err := loadIAMManagerFromConfig(option.IamConfig, func() string {
|
||||
return filerAddr
|
||||
return string(filerClient.GetCurrentFiler())
|
||||
})
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to load IAM configuration: %v", err)
|
||||
} else {
|
||||
// Create S3 IAM integration with the loaded IAM manager
|
||||
s3iam := NewS3IAMIntegration(iamManager, filerAddr)
|
||||
// filerAddress not actually used, just for backward compatibility
|
||||
s3iam := NewS3IAMIntegration(iamManager, "")
|
||||
|
||||
// Set IAM integration in server
|
||||
s3ApiServer.iamIntegration = s3iam
|
||||
@@ -177,7 +171,7 @@ func NewS3ApiServerWithStore(router *mux.Router, option *S3ApiServerOption, expl
|
||||
// Set the integration in the traditional IAM for compatibility
|
||||
iam.SetIAMIntegration(s3iam)
|
||||
|
||||
glog.V(1).Infof("Advanced IAM system initialized successfully")
|
||||
glog.V(1).Infof("Advanced IAM system initialized successfully with HA filer support")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user