File tree 1 file changed +13
-0
lines changed
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.
17
17
package aws
18
18
19
19
import (
20
+ "strings"
21
+
20
22
"github.com/aws/aws-sdk-go/service/iam"
21
23
"github.com/cortexlabs/cortex/pkg/lib/errors"
22
24
)
@@ -50,6 +52,7 @@ func (c *Client) GetGroupsForUser(userName string) ([]iam.Group, error) {
50
52
return groups , nil
51
53
}
52
54
55
+ // Note: root users don't have attached policies, but do have full access
53
56
func (c * Client ) GetManagedPoliciesForUser (userName string ) ([]iam.AttachedPolicy , error ) {
54
57
var policies []iam.AttachedPolicy
55
58
@@ -89,6 +92,16 @@ func (c *Client) IsAdmin() bool {
89
92
return false
90
93
}
91
94
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
+
92
105
policies , err := c .GetManagedPoliciesForUser (* user .UserName )
93
106
if err != nil {
94
107
return false
You can’t perform that action at this time.
0 commit comments