Merge pull request #1157 from versity/sis/iam-root-change-bucket-owner

fix: Changes the GetUserAccount method behavior in single iam mode to…
This commit is contained in:
Ben McClelland
2025-03-20 08:18:21 -07:00
committed by GitHub
2 changed files with 17 additions and 5 deletions
+1 -1
View File
@@ -161,7 +161,7 @@ func New(o *Opts) (IAMService, error) {
default:
// if no iam options selected, default to the single user mode
fmt.Println("No IAM service configured, enabling single account mode")
return IAMServiceSingle{}, nil
return NewIAMServiceSingle(o.RootAccount), nil
}
if err != nil {
+16 -4
View File
@@ -19,18 +19,30 @@ import (
)
// IAMServiceSingle manages the single tenant (root-only) IAM service
type IAMServiceSingle struct{}
type IAMServiceSingle struct {
root Account
}
var _ IAMService = &IAMServiceSingle{}
func NewIAMServiceSingle(r Account) IAMService {
return &IAMServiceSingle{
root: r,
}
}
// CreateAccount not valid in single tenant mode
func (IAMServiceSingle) CreateAccount(account Account) error {
return s3err.GetAPIError(s3err.ErrAdminMethodNotSupported)
}
// GetUserAccount no accounts in single tenant mode
func (IAMServiceSingle) GetUserAccount(access string) (Account, error) {
return Account{}, s3err.GetAPIError(s3err.ErrAdminMethodNotSupported)
// GetUserAccount returns root account, if the root access key
// is provided and "ErrAdminUserNotFound" otherwise
func (s IAMServiceSingle) GetUserAccount(access string) (Account, error) {
if access == s.root.Access {
return s.root, nil
}
return Account{}, s3err.GetAPIError(s3err.ErrAdminUserNotFound)
}
// UpdateUserAccount no accounts in single tenant mode