add accountconfiguration flags to blueprint (#269)

Closes #261
This commit is contained in:
Victor Vrantchan
2017-10-27 00:23:14 -04:00
committed by GitHub
parent 9c9455330a
commit 1defd8b922
5 changed files with 69 additions and 34 deletions

View File

@@ -17,12 +17,14 @@ const (
)
type Blueprint struct {
UUID string `json:"uuid"`
Name string `json:"name"`
ApplicationURLs []string `json:"install_application_manifest_urls"`
ProfileIdentifiers []string `json:"profile_ids"`
UserUUID []string `json:"user_uuids"`
ApplyAt []string `json:"apply_at"`
UUID string `json:"uuid"`
Name string `json:"name"`
ApplicationURLs []string `json:"install_application_manifest_urls"`
ProfileIdentifiers []string `json:"profile_ids"`
UserUUID []string `json:"user_uuids"`
SkipPrimarySetupAccountCreation bool `json:"skip_primary_setup_account_creation"`
SetPrimarySetupAccountAsRegularUser bool `json:"set_primary_setup_account_as_regular_user"`
ApplyAt []string `json:"apply_at"`
}
func (bp *Blueprint) Verify() error {
@@ -34,12 +36,14 @@ func (bp *Blueprint) Verify() error {
func MarshalBlueprint(bp *Blueprint) ([]byte, error) {
protobp := blueprintproto.Blueprint{
Uuid: bp.UUID,
Name: bp.Name,
ManifestUrls: bp.ApplicationURLs,
ProfileIds: bp.ProfileIdentifiers,
UserUuid: bp.UserUUID,
ApplyAt: bp.ApplyAt,
Uuid: bp.UUID,
Name: bp.Name,
ManifestUrls: bp.ApplicationURLs,
ProfileIds: bp.ProfileIdentifiers,
UserUuid: bp.UserUUID,
SkipPrimarySetupAccountCreation: bp.SkipPrimarySetupAccountCreation,
SetPrimarySetupAccountAsRegularUser: bp.SetPrimarySetupAccountAsRegularUser,
ApplyAt: bp.ApplyAt,
}
return proto.Marshal(&protobp)
}
@@ -55,5 +59,7 @@ func UnmarshalBlueprint(data []byte, bp *Blueprint) error {
bp.ProfileIdentifiers = pb.GetProfileIds()
bp.ApplyAt = pb.GetApplyAt()
bp.UserUUID = pb.GetUserUuid()
bp.SkipPrimarySetupAccountCreation = pb.GetSkipPrimarySetupAccountCreation()
bp.SetPrimarySetupAccountAsRegularUser = pb.GetSetPrimarySetupAccountAsRegularUser()
return nil
}

View File

@@ -28,12 +28,14 @@ var _ = math.Inf
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type Blueprint struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
ManifestUrls []string `protobuf:"bytes,3,rep,name=manifest_urls,json=manifestUrls" json:"manifest_urls,omitempty"`
ProfileIds []string `protobuf:"bytes,5,rep,name=profile_ids,json=profileIds" json:"profile_ids,omitempty"`
ApplyAt []string `protobuf:"bytes,6,rep,name=apply_at,json=applyAt" json:"apply_at,omitempty"`
UserUuid []string `protobuf:"bytes,7,rep,name=user_uuid,json=userUuid" json:"user_uuid,omitempty"`
Uuid string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
ManifestUrls []string `protobuf:"bytes,3,rep,name=manifest_urls,json=manifestUrls" json:"manifest_urls,omitempty"`
ProfileIds []string `protobuf:"bytes,5,rep,name=profile_ids,json=profileIds" json:"profile_ids,omitempty"`
ApplyAt []string `protobuf:"bytes,6,rep,name=apply_at,json=applyAt" json:"apply_at,omitempty"`
UserUuid []string `protobuf:"bytes,7,rep,name=user_uuid,json=userUuid" json:"user_uuid,omitempty"`
SkipPrimarySetupAccountCreation bool `protobuf:"varint,8,opt,name=skip_primary_setup_account_creation,json=skipPrimarySetupAccountCreation" json:"skip_primary_setup_account_creation,omitempty"`
SetPrimarySetupAccountAsRegularUser bool `protobuf:"varint,9,opt,name=set_primary_setup_account_as_regular_user,json=setPrimarySetupAccountAsRegularUser" json:"set_primary_setup_account_as_regular_user,omitempty"`
}
func (m *Blueprint) Reset() { *m = Blueprint{} }
@@ -83,6 +85,20 @@ func (m *Blueprint) GetUserUuid() []string {
return nil
}
func (m *Blueprint) GetSkipPrimarySetupAccountCreation() bool {
if m != nil {
return m.SkipPrimarySetupAccountCreation
}
return false
}
func (m *Blueprint) GetSetPrimarySetupAccountAsRegularUser() bool {
if m != nil {
return m.SetPrimarySetupAccountAsRegularUser
}
return false
}
func init() {
proto.RegisterType((*Blueprint)(nil), "blueprintproto.Blueprint")
}
@@ -90,18 +106,23 @@ func init() {
func init() { proto.RegisterFile("blueprint.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 202 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0xcf, 0x3d, 0x4e, 0xc4, 0x30,
0x10, 0x05, 0x60, 0x85, 0xcd, 0x6e, 0xe2, 0x81, 0x00, 0x72, 0x65, 0x44, 0x41, 0x04, 0x4d, 0x2a,
0x1a, 0x4e, 0x00, 0x1d, 0x94, 0x91, 0x52, 0x5b, 0x0e, 0x76, 0xd0, 0x48, 0x8e, 0x6d, 0xf9, 0xa7,
0xe0, 0x82, 0x9c, 0x0b, 0x65, 0x20, 0xdb, 0xbd, 0xf7, 0x3d, 0x17, 0x1e, 0xb8, 0x99, 0x6d, 0x31,
0x21, 0xa2, 0xcb, 0xcf, 0x21, 0xfa, 0xec, 0xf9, 0xf5, 0x19, 0xa8, 0x3f, 0xfe, 0x54, 0xc0, 0xde,
0x76, 0xe2, 0x1c, 0xea, 0x52, 0x50, 0x8b, 0xaa, 0xaf, 0x06, 0x36, 0x52, 0xde, 0xcc, 0xa9, 0xd5,
0x88, 0x8b, 0x3f, 0xdb, 0x32, 0x7f, 0x82, 0x6e, 0x55, 0x0e, 0x17, 0x93, 0xb2, 0x2c, 0xd1, 0x26,
0x71, 0xe8, 0x0f, 0x03, 0x1b, 0xaf, 0x76, 0x9c, 0xa2, 0x4d, 0xfc, 0x01, 0x2e, 0x43, 0xf4, 0x0b,
0x5a, 0x23, 0x51, 0x27, 0x71, 0xa4, 0x27, 0xf0, 0x4f, 0xef, 0x3a, 0xf1, 0x3b, 0x68, 0x55, 0x08,
0xf6, 0x5b, 0xaa, 0x2c, 0x4e, 0xb4, 0x36, 0xd4, 0x5f, 0x33, 0xbf, 0x07, 0x56, 0x92, 0x89, 0x92,
0x7e, 0xd3, 0xd0, 0xd6, 0x6e, 0x30, 0x15, 0xd4, 0x1f, 0x75, 0x5b, 0xdf, 0x1e, 0xc7, 0x6e, 0xf5,
0x33, 0x5a, 0xf3, 0xe9, 0xdd, 0x82, 0x5f, 0x69, 0x3e, 0xd1, 0x3d, 0x2f, 0xbf, 0x01, 0x00, 0x00,
0xff, 0xff, 0xc6, 0x8c, 0x53, 0x51, 0xf2, 0x00, 0x00, 0x00,
// 282 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xbd, 0x4e, 0x2b, 0x31,
0x10, 0x85, 0x95, 0xff, 0x5d, 0xdf, 0x1b, 0x40, 0xae, 0x8c, 0x28, 0x12, 0x91, 0x26, 0x34, 0x34,
0x3c, 0x41, 0xa0, 0x02, 0x51, 0xa0, 0x45, 0xa1, 0xb5, 0xbc, 0xbb, 0xb3, 0x91, 0x85, 0xd7, 0xb6,
0x66, 0xec, 0x22, 0xef, 0xcc, 0x43, 0x20, 0x7b, 0x13, 0x2a, 0xe8, 0x66, 0xbe, 0xf9, 0x74, 0x7c,
0x64, 0x76, 0x59, 0x9b, 0x08, 0x1e, 0xb5, 0x0d, 0xf7, 0x1e, 0x5d, 0x70, 0xfc, 0xe2, 0x07, 0xe4,
0xfd, 0xf6, 0x6b, 0xcc, 0xca, 0xc7, 0x33, 0xe2, 0x9c, 0x4d, 0x63, 0xd4, 0xad, 0x18, 0xad, 0x47,
0xdb, 0xb2, 0xca, 0x73, 0x62, 0x56, 0xf5, 0x20, 0xc6, 0x03, 0x4b, 0x33, 0xdf, 0xb0, 0x65, 0xaf,
0xac, 0xee, 0x80, 0x82, 0x8c, 0x68, 0x48, 0x4c, 0xd6, 0x93, 0x6d, 0x59, 0xfd, 0x3f, 0xc3, 0x3d,
0x1a, 0xe2, 0x2b, 0xf6, 0xcf, 0xa3, 0xeb, 0xb4, 0x01, 0xa9, 0x5b, 0x12, 0xb3, 0xac, 0xb0, 0x13,
0x7a, 0x6e, 0x89, 0x5f, 0xb3, 0x42, 0x79, 0x6f, 0x8e, 0x52, 0x05, 0x31, 0xcf, 0xd7, 0x45, 0xde,
0x77, 0x81, 0xdf, 0xb0, 0x32, 0x12, 0xa0, 0xcc, 0x6d, 0x16, 0xf9, 0x56, 0x24, 0xb0, 0x4f, 0x8d,
0x5e, 0xd9, 0x86, 0x3e, 0xb5, 0x97, 0x1e, 0x75, 0xaf, 0xf0, 0x28, 0x09, 0x42, 0xf4, 0x52, 0x35,
0x8d, 0x8b, 0x36, 0xc8, 0x06, 0x41, 0x05, 0xed, 0xac, 0x28, 0xd6, 0xa3, 0x6d, 0x51, 0xad, 0x92,
0xfa, 0x36, 0x98, 0xef, 0x49, 0xdc, 0x0d, 0xde, 0xd3, 0x49, 0xe3, 0x1f, 0xec, 0x8e, 0x20, 0xfc,
0x11, 0xa6, 0x48, 0x22, 0x1c, 0xa2, 0x51, 0x28, 0xd3, 0xf3, 0xa2, 0xcc, 0x99, 0x1b, 0x82, 0xf0,
0x4b, 0xe4, 0x8e, 0xaa, 0xc1, 0xdd, 0x13, 0xe0, 0xcb, 0xb4, 0x98, 0x5e, 0xcd, 0xaa, 0x65, 0xef,
0x6a, 0x6d, 0xa0, 0x71, 0xb6, 0xd3, 0x07, 0xaa, 0xe7, 0xf9, 0xd7, 0x1f, 0xbe, 0x03, 0x00, 0x00,
0xff, 0xff, 0x22, 0x48, 0x96, 0x88, 0x98, 0x01, 0x00, 0x00,
}

View File

@@ -12,4 +12,6 @@ message Blueprint {
repeated string profile_ids = 5;
repeated string apply_at = 6;
repeated string user_uuid = 7;
bool skip_primary_setup_account_creation= 8 ;
bool set_primary_setup_account_as_regular_user = 9;
}

View File

@@ -28,8 +28,8 @@ func (db *DB) ApplyToDevice(ctx context.Context, svc command.Service, bp *Bluepr
Command: mdm.Command{
RequestType: "AccountConfiguration",
AccountConfiguration: mdm.AccountConfiguration{
SkipPrimarySetupAccountCreation: true,
SetPrimarySetupAccountAsRegularUser: false,
SkipPrimarySetupAccountCreation: bp.SkipPrimarySetupAccountCreation,
SetPrimarySetupAccountAsRegularUser: bp.SetPrimarySetupAccountAsRegularUser,
AutoSetupAdminAccounts: []mdm.AdminAccount{
mdm.AdminAccount{
ShortName: u.UserShortname,

View File

@@ -137,6 +137,12 @@ func (cmd *applyCommand) applyBlueprint(args []string) error {
if err != nil {
return err
}
// validate the blueprint account rules
if len(blpt.UserUUID) == 0 && (blpt.SkipPrimarySetupAccountCreation || blpt.SetPrimarySetupAccountAsRegularUser) {
return errors.New("SkipPrimarySetupAccountCreation and SetPrimarySetupAccountAsRegularUser can only be true if there is an account in the UserUUID array.")
}
ctx := context.Background()
err = cmd.applysvc.ApplyBlueprint(ctx, &blpt)
if err != nil {