|
@ -204,6 +204,7 @@ func (iama *IamApiServer) CreatePolicy(s3cfg *iam_pb.S3ApiConfiguration, values |
|
|
return resp, nil |
|
|
return resp, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// https://docs.aws.amazon.com/IAM/latest/APIReference/API_PutUserPolicy.html
|
|
|
func (iama *IamApiServer) PutUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values url.Values) (resp PutUserPolicyResponse, err error) { |
|
|
func (iama *IamApiServer) PutUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values url.Values) (resp PutUserPolicyResponse, err error) { |
|
|
userName := values.Get("UserName") |
|
|
userName := values.Get("UserName") |
|
|
policyName := values.Get("PolicyName") |
|
|
policyName := values.Get("PolicyName") |
|
@ -215,14 +216,15 @@ func (iama *IamApiServer) PutUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values |
|
|
policyDocuments[policyName] = &policyDocument |
|
|
policyDocuments[policyName] = &policyDocument |
|
|
actions := GetActions(&policyDocument) |
|
|
actions := GetActions(&policyDocument) |
|
|
for _, ident := range s3cfg.Identities { |
|
|
for _, ident := range s3cfg.Identities { |
|
|
if userName == ident.Name { |
|
|
|
|
|
for _, action := range actions { |
|
|
|
|
|
ident.Actions = append(ident.Actions, action) |
|
|
|
|
|
} |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
if userName != ident.Name { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
for _, action := range actions { |
|
|
|
|
|
ident.Actions = append(ident.Actions, action) |
|
|
} |
|
|
} |
|
|
|
|
|
return resp, nil |
|
|
} |
|
|
} |
|
|
return resp, nil |
|
|
|
|
|
|
|
|
return resp, fmt.Errorf("%s: the user with name %s cannot be found", iam.ErrCodeNoSuchEntityException, userName) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (iama *IamApiServer) GetUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values url.Values) (resp GetUserPolicyResponse, err error) { |
|
|
func (iama *IamApiServer) GetUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values url.Values) (resp GetUserPolicyResponse, err error) { |
|
@ -412,14 +414,11 @@ func (iama *IamApiServer) DoActions(w http.ResponseWriter, r *http.Request) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
values := r.PostForm |
|
|
values := r.PostForm |
|
|
var s3cfgLock sync.RWMutex |
|
|
|
|
|
s3cfgLock.RLock() |
|
|
|
|
|
s3cfg := &iam_pb.S3ApiConfiguration{} |
|
|
s3cfg := &iam_pb.S3ApiConfiguration{} |
|
|
if err := iama.s3ApiConfig.GetS3ApiConfiguration(s3cfg); err != nil { |
|
|
if err := iama.s3ApiConfig.GetS3ApiConfiguration(s3cfg); err != nil { |
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError) |
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
s3cfgLock.RUnlock() |
|
|
|
|
|
|
|
|
|
|
|
glog.V(4).Infof("DoActions: %+v", values) |
|
|
glog.V(4).Infof("DoActions: %+v", values) |
|
|
var response interface{} |
|
|
var response interface{} |
|
@ -498,9 +497,7 @@ func (iama *IamApiServer) DoActions(w http.ResponseWriter, r *http.Request) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if changed { |
|
|
if changed { |
|
|
s3cfgLock.Lock() |
|
|
|
|
|
err := iama.s3ApiConfig.PutS3ApiConfiguration(s3cfg) |
|
|
err := iama.s3ApiConfig.PutS3ApiConfiguration(s3cfg) |
|
|
s3cfgLock.Unlock() |
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
writeIamErrorResponse(w, r, fmt.Errorf(iam.ErrCodeServiceFailureException), "", "", err) |
|
|
writeIamErrorResponse(w, r, fmt.Errorf(iam.ErrCodeServiceFailureException), "", "", err) |
|
|
return |
|
|
return |
|
|