Merge pull request #2220 from influxdata/multitenancy_default_org_role

Add default role organization
pull/2243/head
Michael Desa 2017-11-06 10:10:29 -05:00 committed by GitHub
commit 7f7674d829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 187 additions and 90 deletions

View File

@ -509,8 +509,9 @@ func UnmarshalRolePB(data []byte, r *Role) error {
// MarshalOrganization encodes a organization to binary protobuf format.
func MarshalOrganization(o *chronograf.Organization) ([]byte, error) {
return MarshalOrganizationPB(&Organization{
ID: o.ID,
Name: o.Name,
ID: o.ID,
Name: o.Name,
DefaultRole: o.DefaultRole,
})
}
@ -527,6 +528,7 @@ func UnmarshalOrganization(data []byte, o *chronograf.Organization) error {
}
o.ID = pb.ID
o.Name = pb.Name
o.DefaultRole = pb.DefaultRole
return nil
}

View File

@ -385,8 +385,9 @@ func (m *Role) GetName() string {
}
type Organization 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"`
ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"`
DefaultRole string `protobuf:"bytes,3,opt,name=DefaultRole,proto3" json:"DefaultRole,omitempty"`
}
func (m *Organization) Reset() { *m = Organization{} }
@ -394,6 +395,27 @@ func (m *Organization) String() string { return proto.CompactTextStri
func (*Organization) ProtoMessage() {}
func (*Organization) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{15} }
func (m *Organization) GetID() uint64 {
if m != nil {
return m.ID
}
return 0
}
func (m *Organization) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *Organization) GetDefaultRole() string {
if m != nil {
return m.DefaultRole
}
return ""
}
func init() {
proto.RegisterType((*Source)(nil), "internal.Source")
proto.RegisterType((*Dashboard)(nil), "internal.Dashboard")
@ -416,76 +438,76 @@ func init() {
func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) }
var fileDescriptorInternal = []byte{
// 1123 bytes of a gzipped FileDescriptorProto
// 1133 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, 0x2a, 0x6a, 0x8a, 0x84, 0x82, 0x05, 0x52,
0x90, 0xe8, 0x82, 0xb6, 0x42, 0x42, 0x1c, 0x90, 0xb2, 0x1b, 0x54, 0x2d, 0xbb, 0x6d, 0x97, 0xc9,
0x14, 0x96, 0x63, 0x3b, 0x89, 0x5f, 0xb6, 0x0b, 0x1a, 0x55, 0xd4, 0x14, 0x09, 0x05, 0x0b, 0xa4,
0x20, 0xd1, 0x05, 0xb5, 0x42, 0x42, 0x1c, 0x90, 0xb2, 0x1b, 0x54, 0x2d, 0xbb, 0x6d, 0x97, 0xc9,
0xee, 0x72, 0x42, 0xd5, 0xc4, 0x79, 0x49, 0xac, 0x3a, 0xb1, 0x19, 0xdb, 0xbb, 0x31, 0xff, 0x0d,
0x12, 0x27, 0x8e, 0x88, 0x3b, 0x12, 0x27, 0xd4, 0x23, 0x7f, 0x11, 0x7a, 0x33, 0x63, 0xc7, 0x21,
0xa1, 0xda, 0x0b, 0xdc, 0xe6, 0x7b, 0x6f, 0xfc, 0xe6, 0xfd, 0xfa, 0x3e, 0x19, 0xee, 0x47, 0xab,
0x1c, 0xe5, 0x4a, 0xc4, 0x87, 0xa9, 0x4c, 0xf2, 0x84, 0x75, 0x2b, 0x1c, 0xfc, 0xd5, 0x82, 0xf6,
0x38, 0x29, 0x64, 0x88, 0xec, 0x3e, 0xb4, 0x4e, 0x47, 0xbe, 0xd5, 0xb7, 0x06, 0x36, 0x6f, 0x9d,
0x8e, 0x18, 0x03, 0xe7, 0xb9, 0x58, 0xa2, 0xdf, 0xea, 0x5b, 0x03, 0x8f, 0xab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0x1d, 0x00, 0x00, 0xff, 0xff, 0x65, 0x9d, 0x67, 0xe0, 0x48, 0x0b, 0x00, 0x00,
}

View File

@ -144,6 +144,7 @@ message Role {
message Organization {
uint64 ID = 1; // ID is the unique ID of the organization
string Name = 2; // Name is the organization's name
string DefaultRole = 3; // DefaultRole is the name of the role that is the default for any users added to the organization
}
// The following is a vim modeline, it autoconfigures vim to have the

View File

@ -24,8 +24,9 @@ type OrganizationsStore struct {
// Migrate sets the default organization at runtime
func (s *OrganizationsStore) Migrate(ctx context.Context) error {
o := chronograf.Organization{
ID: 0,
Name: "__default",
ID: 0,
Name: "__default",
DefaultRole: "member",
}
return s.client.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket(OrganizationsBucket)

View File

@ -183,7 +183,8 @@ func TestOrganizationsStore_All(t *testing.T) {
},
want: []chronograf.Organization{
{
Name: "__default",
Name: "__default",
DefaultRole: "member",
},
{
Name: "EE - Evil Empire",

View File

@ -773,6 +773,8 @@ type LayoutsStore interface {
type Organization struct {
ID uint64 `json:"id,string"`
Name string `json:"name"`
// DefaultRole is the name of the role that is the default for any users added to the organization
DefaultRole string `json:"defaultRole,omitempty"`
}
// OrganizationQuery represents the attributes that a organization may be retrieved by.

View File

@ -197,6 +197,20 @@ func (s *Service) Me(w http.ResponseWriter, r *http.Request) {
unknownErrorWithMessage(w, err, s.Logger)
return
}
// If a user was added via the API, they might not yet be a member of the default organization
// Here we check to verify that they are a user in the default organization
// TODO(desa): when https://github.com/influxdata/chronograf/pull/2219 is merge, refactor this to use
// the default organization logic rather than hard coding valies here.
if !hasRoleInDefaultOrganization(usr) {
usr.Roles = append(usr.Roles, chronograf.Role{
Organization: "0",
Name: MemberRoleName,
})
if err := s.Store.Users(ctx).Update(ctx, usr); err != nil {
unknownErrorWithMessage(w, err, s.Logger)
return
}
}
res := newMeResponse(usr)
res.Organizations = orgs
res.CurrentOrganization = currentOrg
@ -284,3 +298,15 @@ func (s *Service) usersOrganizations(ctx context.Context, u *chronograf.User) ([
return orgs, nil
}
// TODO(desa): when https://github.com/influxdata/chronograf/pull/2219 is merge, refactor this to use
// the default organization logic rather than hard coding valies here.
func hasRoleInDefaultOrganization(u *chronograf.User) bool {
for _, role := range u.Roles {
if role.Organization == "0" {
return true
}
}
return false
}

View File

@ -70,6 +70,9 @@ func TestService_Me(t *testing.T) {
Scheme: "oauth2",
}, nil
},
UpdateF: func(ctx context.Context, u *chronograf.User) error {
return nil
},
},
},
principal: oauth2.Principal{
@ -78,7 +81,7 @@ func TestService_Me(t *testing.T) {
},
wantStatus: http.StatusOK,
wantContentType: "application/json",
wantBody: `{"name":"me","provider":"github","scheme":"oauth2","links":{"self":"/chronograf/v1/users/0"},"currentOrganization":{"id":"0","name":"The Bad Place"}}
wantBody: `{"name":"me","provider":"github","scheme":"oauth2","links":{"self":"/chronograf/v1/users/0"},"currentOrganization":{"id":"0","name":"The Bad Place"},"roles":[{"name":"member","organization":"0"}]}
`,
},
{
@ -112,6 +115,9 @@ func TestService_Me(t *testing.T) {
AddF: func(ctx context.Context, u *chronograf.User) (*chronograf.User, error) {
return u, nil
},
UpdateF: func(ctx context.Context, u *chronograf.User) error {
return nil
},
},
},
principal: oauth2.Principal{
@ -150,6 +156,9 @@ func TestService_Me(t *testing.T) {
AddF: func(ctx context.Context, u *chronograf.User) (*chronograf.User, error) {
return nil, fmt.Errorf("Why Heavy?")
},
UpdateF: func(ctx context.Context, u *chronograf.User) error {
return nil
},
},
Logger: log.New(log.DebugLevel),
},
@ -216,7 +225,10 @@ func TestService_Me(t *testing.T) {
if tt.wantContentType != "" && content != tt.wantContentType {
t.Errorf("%q. Me() = %v, want %v", tt.name, content, tt.wantContentType)
}
if tt.wantBody != "" && string(body) != tt.wantBody {
if tt.wantBody == "" {
continue
}
if eq, err := jsonEqual(tt.wantBody, string(body)); err != nil || !eq {
t.Errorf("%q. Me() = \n***%v***\n,\nwant\n***%v***", tt.name, string(body), tt.wantBody)
}
}
@ -274,6 +286,9 @@ func TestService_MeOrganizations(t *testing.T) {
},
}, nil
},
UpdateF: func(ctx context.Context, u *chronograf.User) error {
return nil
},
},
OrganizationsStore: &mocks.OrganizationsStore{
GetF: func(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {
@ -293,7 +308,7 @@ func TestService_MeOrganizations(t *testing.T) {
},
wantStatus: http.StatusOK,
wantContentType: "application/json",
wantBody: `{"name":"me","roles":[{"name":"admin","organization":"1337"}],"provider":"github","scheme":"oauth2","links":{"self":"/chronograf/v1/users/0"},"organizations":[{"id":"1337","name":"The ShillBillThrilliettas"}],"currentOrganization":{"id":"1337","name":"The ShillBillThrilliettas"}}`,
wantBody: `{"name":"me","roles":[{"name":"admin","organization":"1337"},{"name":"member","organization":"0"}],"provider":"github","scheme":"oauth2","links":{"self":"/chronograf/v1/users/0"},"organizations":[{"id":"1337","name":"The ShillBillThrilliettas"}],"currentOrganization":{"id":"1337","name":"The ShillBillThrilliettas"}}`,
},
{
name: "Change the current User's organization",
@ -325,6 +340,9 @@ func TestService_MeOrganizations(t *testing.T) {
},
}, nil
},
UpdateF: func(ctx context.Context, u *chronograf.User) error {
return nil
},
},
OrganizationsStore: &mocks.OrganizationsStore{
GetF: func(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {
@ -345,7 +363,7 @@ func TestService_MeOrganizations(t *testing.T) {
},
wantStatus: http.StatusOK,
wantContentType: "application/json",
wantBody: `{"name":"me","roles":[{"name":"admin","organization":"1337"}],"provider":"github","scheme":"oauth2","links":{"self":"/chronograf/v1/users/0"},"organizations":[{"id":"1337","name":"The ThrillShilliettos"}],"currentOrganization":{"id":"1337","name":"The ThrillShilliettos"}}
wantBody: `{"name":"me","roles":[{"name":"admin","organization":"1337"},{"name":"member","organization":"0"}],"provider":"github","scheme":"oauth2","links":{"self":"/chronograf/v1/users/0"},"organizations":[{"id":"1337","name":"The ThrillShilliettos"}],"currentOrganization":{"id":"1337","name":"The ThrillShilliettos"}}
`,
},
{
@ -368,6 +386,9 @@ func TestService_MeOrganizations(t *testing.T) {
}
return nil, chronograf.ErrUserNotFound
},
UpdateF: func(ctx context.Context, u *chronograf.User) error {
return nil
},
},
OrganizationsStore: &mocks.OrganizationsStore{
GetF: func(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {
@ -420,6 +441,9 @@ func TestService_MeOrganizations(t *testing.T) {
},
}, nil
},
UpdateF: func(ctx context.Context, u *chronograf.User) error {
return nil
},
},
OrganizationsStore: &mocks.OrganizationsStore{
GetF: func(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {

View File

@ -15,33 +15,50 @@ func parseOrganizationID(id string) (uint64, error) {
}
type organizationRequest struct {
Name string `json:"name"`
Name string `json:"name"`
DefaultRole string `json:"defaultRole"`
}
func (r *organizationRequest) ValidCreate() error {
if r.Name == "" {
return fmt.Errorf("Name required on Chronograf Organization request body")
}
return nil
return r.ValidDefaultRole()
}
func (r *organizationRequest) ValidUpdate() error {
if r.Name == "" {
if r.Name == "" && r.DefaultRole == "" {
return fmt.Errorf("No fields to update")
}
return nil
return r.ValidDefaultRole()
}
func (r *organizationRequest) ValidDefaultRole() error {
if r.DefaultRole == "" {
r.DefaultRole = MemberRoleName
}
switch r.DefaultRole {
case MemberRoleName, ViewerRoleName, EditorRoleName, AdminRoleName:
return nil
default:
return fmt.Errorf("default role must be member, viewer, editor, or admin")
}
}
type organizationResponse struct {
Links selfLinks `json:"links"`
ID uint64 `json:"id,string"`
Name string `json:"name"`
Links selfLinks `json:"links"`
ID uint64 `json:"id,string"`
Name string `json:"name"`
DefaultRole string `json:"defaultRole,omitempty"`
}
func newOrganizationResponse(o *chronograf.Organization) *organizationResponse {
return &organizationResponse{
ID: o.ID,
Name: o.Name,
ID: o.ID,
Name: o.Name,
DefaultRole: o.DefaultRole,
Links: selfLinks{
Self: fmt.Sprintf("/chronograf/v1/organizations/%d", o.ID),
},
@ -95,7 +112,8 @@ func (s *Service) NewOrganization(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
org := &chronograf.Organization{
Name: req.Name,
Name: req.Name,
DefaultRole: req.DefaultRole,
}
res, err := s.Store.Organizations(ctx).Add(ctx, org)