File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ limitations under the License.
1717package aws
1818
1919import (
20+ "strings"
21+
2022 "github.com/aws/aws-sdk-go/service/iam"
2123 "github.com/cortexlabs/cortex/pkg/lib/errors"
2224)
@@ -50,6 +52,7 @@ func (c *Client) GetGroupsForUser(userName string) ([]iam.Group, error) {
5052 return groups , nil
5153}
5254
55+ // Note: root users don't have attached policies, but do have full access
5356func (c * Client ) GetManagedPoliciesForUser (userName string ) ([]iam.AttachedPolicy , error ) {
5457 var policies []iam.AttachedPolicy
5558
@@ -89,6 +92,16 @@ func (c *Client) IsAdmin() bool {
8992 return false
9093 }
9194
95+ // Root users may not have a user name
96+ if user .UserName == nil {
97+ return true
98+ }
99+
100+ // Root users may have a user name
101+ if user .Arn == nil || strings .HasSuffix (* user .Arn , ":root" ) {
102+ return true
103+ }
104+
92105 policies , err := c .GetManagedPoliciesForUser (* user .UserName )
93106 if err != nil {
94107 return false
You can’t perform that action at this time.
0 commit comments