From 391bd189c1a5d7080b4420180ac2e091c276b4d6 Mon Sep 17 00:00:00 2001 From: Michael Desa Date: Tue, 31 Oct 2017 18:27:24 -0400 Subject: [PATCH] Add support for super admin --- bolt/internal/internal.go | 12 ++- bolt/internal/internal.pb.go | 189 +++++++++++++++++++++-------------- bolt/internal/internal.proto | 3 +- chronograf.go | 1 + server/auth.go | 24 ++++- 5 files changed, 146 insertions(+), 83 deletions(-) diff --git a/bolt/internal/internal.go b/bolt/internal/internal.go index c69177fbf..e788bd74a 100644 --- a/bolt/internal/internal.go +++ b/bolt/internal/internal.go @@ -425,11 +425,12 @@ func MarshalUser(u *chronograf.User) ([]byte, error) { } } return MarshalUserPB(&User{ - ID: u.ID, - Name: u.Name, - Provider: u.Provider, - Scheme: u.Scheme, - Roles: roles, + ID: u.ID, + Name: u.Name, + Provider: u.Provider, + Scheme: u.Scheme, + Roles: roles, + SuperAdmin: u.SuperAdmin, }) } @@ -457,6 +458,7 @@ func UnmarshalUser(data []byte, u *chronograf.User) error { u.Name = pb.Name u.Provider = pb.Provider u.Scheme = pb.Scheme + u.SuperAdmin = pb.SuperAdmin u.Roles = roles return nil diff --git a/bolt/internal/internal.pb.go b/bolt/internal/internal.pb.go index 6e9625db1..7ed1b0272 100644 --- a/bolt/internal/internal.pb.go +++ b/bolt/internal/internal.pb.go @@ -305,11 +305,12 @@ func (*AlertRule) ProtoMessage() {} func (*AlertRule) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{12} } type User struct { - ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` - Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` - Provider string `protobuf:"bytes,3,opt,name=Provider,proto3" json:"Provider,omitempty"` - Scheme string `protobuf:"bytes,4,opt,name=Scheme,proto3" json:"Scheme,omitempty"` - Roles []*Role `protobuf:"bytes,5,rep,name=Roles" json:"Roles,omitempty"` + ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` + Provider string `protobuf:"bytes,3,opt,name=Provider,proto3" json:"Provider,omitempty"` + Scheme string `protobuf:"bytes,4,opt,name=Scheme,proto3" json:"Scheme,omitempty"` + Roles []*Role `protobuf:"bytes,5,rep,name=Roles" json:"Roles,omitempty"` + SuperAdmin bool `protobuf:"varint,6,opt,name=SuperAdmin,proto3" json:"SuperAdmin,omitempty"` } func (m *User) Reset() { *m = User{} } @@ -317,6 +318,34 @@ func (m *User) String() string { return proto.CompactTextString(m) } func (*User) ProtoMessage() {} func (*User) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{13} } +func (m *User) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *User) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *User) GetProvider() string { + if m != nil { + return m.Provider + } + return "" +} + +func (m *User) GetScheme() string { + if m != nil { + return m.Scheme + } + return "" +} + func (m *User) GetRoles() []*Role { if m != nil { return m.Roles @@ -324,6 +353,13 @@ func (m *User) GetRoles() []*Role { return nil } +func (m *User) GetSuperAdmin() bool { + if m != nil { + return m.SuperAdmin + } + return false +} + type Role struct { Organization string `protobuf:"bytes,1,opt,name=Organization,proto3" json:"Organization,omitempty"` Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` @@ -380,75 +416,76 @@ func init() { func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) } var fileDescriptorInternal = []byte{ - // 1109 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0xe3, 0xc4, - 0x17, 0x97, 0x63, 0x3b, 0x89, 0x5f, 0xba, 0xfd, 0x7e, 0x35, 0x5a, 0xb1, 0x66, 0xb9, 0x04, 0x0b, - 0xa4, 0x20, 0xb1, 0x05, 0x75, 0x85, 0x84, 0x38, 0x20, 0xa5, 0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d, 0x53, 0x1d, 0xde, 0x9a, 0x8b, - 0x32, 0x73, 0xed, 0xa5, 0xa0, 0xfa, 0xdf, 0xc9, 0x2c, 0xb9, 0x41, 0xc1, 0x53, 0xf3, 0x39, 0x45, - 0xbf, 0x4e, 0x53, 0x94, 0x86, 0xaa, 0x1a, 0xa8, 0x37, 0x93, 0x3b, 0xd4, 0x2a, 0x6b, 0x73, 0x0d, - 0x82, 0xef, 0xc0, 0x1b, 0xc6, 0x28, 0x73, 0x5e, 0xc4, 0xbb, 0xda, 0xcc, 0xc0, 0xf9, 0x7a, 0xfc, - 0xf2, 0x45, 0x45, 0x70, 0x3a, 0x6f, 0x68, 0x69, 0xff, 0x8d, 0x96, 0xe7, 0x22, 0x15, 0x67, 0x23, - 0xb5, 0x67, 0x36, 0x37, 0x28, 0xf8, 0xd1, 0x02, 0x87, 0xf8, 0xdf, 0x08, 0xed, 0xbc, 0x4d, 0x3b, - 0x2e, 0x65, 0x72, 0x1b, 0x4d, 0x51, 0x56, 0xda, 0x51, 0x61, 0x55, 0x74, 0xb8, 0xc0, 0xfa, 0x67, - 0xcf, 0x20, 0x9a, 0x35, 0x4f, 0xe2, 0x7a, 0x97, 0x1b, 0xb3, 0x26, 0x33, 0xd7, 0xce, 0xe0, 0x4b, - 0x70, 0xe8, 0xb0, 0x43, 0x30, 0x6b, 0x97, 0x60, 0xfb, 0x32, 0x0b, 0x8e, 0xb7, 0xbf, 0xbb, 0x4f, - 0x35, 0x93, 0xb6, 0xfa, 0xe9, 0x7d, 0xfa, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0c, 0xe0, 0x82, - 0xca, 0x06, 0x0b, 0x00, 0x00, + // 1123 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x8f, 0xdb, 0x44, + 0x14, 0x96, 0x63, 0x3b, 0x89, 0x5f, 0xb6, 0x05, 0x8d, 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+ 0x0b, 0x00, 0x00, } diff --git a/bolt/internal/internal.proto b/bolt/internal/internal.proto index f4c56de5f..4ea2063e2 100644 --- a/bolt/internal/internal.proto +++ b/bolt/internal/internal.proto @@ -133,11 +133,12 @@ message User { string Provider = 3; // Provider is the provider that certifies and issues this user's authentication, e.g. GitHub string Scheme = 4; // Scheme is the scheme used to perform this user's authentication, e.g. OAuth2 or LDAP repeated Role Roles = 5; // Roles is set of roles a user has + bool SuperAdmin = 6; // SuperAdmin is bool that specifies whether a user is a super admin } message Role { string Organization = 1; // Organization is the ID of the organization that this user has a role in - string Name = 2; // Name is the name of the role of this user in the respective organization + string Name = 2; // Name is the name of the role of this user in the respective organization } message Organization { diff --git a/chronograf.go b/chronograf.go index c8ec2506b..865e26b01 100644 --- a/chronograf.go +++ b/chronograf.go @@ -626,6 +626,7 @@ type User struct { Provider string `json:"provider,omitempty"` Scheme string `json:"scheme,omitempty"` CurrentOrganization string `json:"currentOrganization,omitempty"` + SuperAdmin bool `json:"superAdmin,omitempty"` } // UserQuery represents the attributes that a user may be retrieved by. diff --git a/server/auth.go b/server/auth.go index 3b7091764..4de437c71 100644 --- a/server/auth.go +++ b/server/auth.go @@ -105,7 +105,29 @@ func AuthorizedUser( } ctx = context.WithValue(ctx, "organizationID", p.Organization) - u, err := store.Users(ctx).Get(ctx, chronograf.UserQuery{ + // TODO: add real implementation + serverCtx := context.WithValue(ctx, "superadmin", true) + // TODO: seems silly to look up a user twice + u, err := store.Users(serverCtx).Get(serverCtx, chronograf.UserQuery{ + Name: &p.Subject, + Provider: &p.Issuer, + Scheme: &scheme, + }) + + if err != nil { + log.Error("Failed to retrieve user") + Error(w, http.StatusUnauthorized, "User is not authorized", logger) + return + } + + if u.SuperAdmin { + // This context is where superadmin gets set for all things + r = r.WithContext(serverCtx) + next(w, r) + return + } + + u, err = store.Users(ctx).Get(ctx, chronograf.UserQuery{ Name: &p.Subject, Provider: &p.Issuer, Scheme: &scheme,