diff --git a/auth/iam.go b/auth/iam.go index 7f6d21a0..b8e7cdd2 100644 --- a/auth/iam.go +++ b/auth/iam.go @@ -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 { diff --git a/auth/iam_single.go b/auth/iam_single.go index ed0156e8..9cf3e249 100644 --- a/auth/iam_single.go +++ b/auth/iam_single.go @@ -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