mirror of
https://github.com/micromdm/micromdm/
synced 2026-06-24 14:35:47 +08:00
mdm: add SetBootstrapToken command.
This commit is contained in:
@@ -60,6 +60,7 @@ type Command struct {
|
||||
ScheduleOSUpdateScan *ScheduleOSUpdateScan
|
||||
ActiveNSExtensions *ActiveNSExtensions
|
||||
RotateFileVaultKey *RotateFileVaultKey
|
||||
SetBootstrapToken *SetBootstrapToken
|
||||
}
|
||||
|
||||
// InstallProfile is an InstallProfile MDM Command
|
||||
@@ -250,6 +251,10 @@ type SetAutoAdminPassword struct {
|
||||
PasswordHash []byte `plist:"passwordHash" json:"password_hash"`
|
||||
}
|
||||
|
||||
type SetBootstrapToken struct {
|
||||
BootstrapToken string `plist:",omitempty" json:"bootstrap_token,omitempty"`
|
||||
}
|
||||
|
||||
type OSUpdate struct {
|
||||
ProductKey string `json:"product_key"`
|
||||
InstallAction string `json:"install_action"`
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -66,6 +66,7 @@ message Command {
|
||||
ActiveNSExtensions active_ns_extensions = 34;
|
||||
RotateFileVaultKey rotate_filevault_key = 35;
|
||||
InstallEnterpriseApplication install_enterprise_application = 36;
|
||||
SetBootstrapToken set_bootstrap_token = 37;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,6 +390,11 @@ message FileVaultUnlock {
|
||||
string private_key_export_password = 3;
|
||||
}
|
||||
|
||||
message SetBootstrapToken {
|
||||
string bootstrap_token = 1;
|
||||
}
|
||||
|
||||
|
||||
message ResultPayload {
|
||||
enum Status {
|
||||
Acknowledged = 0;
|
||||
|
||||
@@ -347,6 +347,15 @@ func (c *Command) MarshalJSON() ([]byte, error) {
|
||||
RotateFileVaultKey: c.RotateFileVaultKey,
|
||||
}
|
||||
return json.Marshal(&x)
|
||||
case "SetBootstrapToken":
|
||||
var x = struct {
|
||||
RequestType string `json:"request_type"`
|
||||
*SetBootstrapToken
|
||||
}{
|
||||
RequestType: c.RequestType,
|
||||
SetBootstrapToken: c.SetBootstrapToken,
|
||||
}
|
||||
return json.Marshal(&x)
|
||||
default:
|
||||
return nil, fmt.Errorf("mdm: unknown RequestType: %s", c.RequestType)
|
||||
}
|
||||
|
||||
@@ -325,6 +325,14 @@ func (c *Command) MarshalPlist() (interface{}, error) {
|
||||
RequestType: c.RequestType,
|
||||
RotateFileVaultKey: c.RotateFileVaultKey,
|
||||
}, nil
|
||||
case "SetBootstrapToken":
|
||||
return &struct {
|
||||
RequestType string
|
||||
*SetBootstrapToken
|
||||
}{
|
||||
RequestType: c.RequestType,
|
||||
SetBootstrapToken: c.SetBootstrapToken,
|
||||
}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("mdm: unknown command RequestType, %s", c.RequestType)
|
||||
}
|
||||
|
||||
@@ -286,6 +286,12 @@ func commandToProto(cmd *Command) (*mdmproto.Command, error) {
|
||||
AllowOroms: cmd.SetFirmwarePassword.AllowOroms,
|
||||
},
|
||||
}
|
||||
case "SetBootstrapToken":
|
||||
cmdproto.Request = &mdmproto.Command_SetBootstrapToken{
|
||||
SetBootstrapToken: &mdmproto.SetBootstrapToken{
|
||||
BootstrapToken: cmd.SetBootstrapToken.BootstrapToken,
|
||||
},
|
||||
}
|
||||
case "VerifyFirmwarePassword":
|
||||
cmdproto.Request = &mdmproto.Command_VerifyFirmwarePassword{
|
||||
VerifyFirmwarePassword: &mdmproto.VerifyFirmwarePassword{
|
||||
|
||||
@@ -295,6 +295,13 @@ func (c *Command) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
c.RotateFileVaultKey = &payload
|
||||
return nil
|
||||
case "SetBootstrapToken":
|
||||
var payload SetBootstrapToken
|
||||
if err := json.Unmarshal(data, &payload); err != nil {
|
||||
return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType)
|
||||
}
|
||||
c.SetBootstrapToken = &payload
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("mdm: unknown RequestType: %s", c.RequestType)
|
||||
}
|
||||
|
||||
@@ -281,6 +281,13 @@ func (c *Command) UnmarshalPlist(unmarshal func(i interface{}) error) error {
|
||||
}
|
||||
c.RotateFileVaultKey = &payload
|
||||
return nil
|
||||
case "SetBootstrapToken":
|
||||
var payload SetBootstrapToken
|
||||
if err := unmarshal(&payload); err != nil {
|
||||
return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType)
|
||||
}
|
||||
c.SetBootstrapToken = &payload
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("mdm: unknown RequestType: %s", requestType.RequestType)
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func protoToCommand(pb *mdmproto.Command) *Command {
|
||||
options = &InstallApplicationOptions{
|
||||
PurchaseMethod: new(int64),
|
||||
}
|
||||
*options.PurchaseMethod = pboptions.GetPurchaseMethod();
|
||||
*options.PurchaseMethod = pboptions.GetPurchaseMethod()
|
||||
}
|
||||
|
||||
pbconfig := pbc.GetConfiguration()
|
||||
@@ -245,6 +245,11 @@ func protoToCommand(pb *mdmproto.Command) *Command {
|
||||
NewPassword: pbc.GetNewPassword(),
|
||||
AllowOroms: pbc.GetAllowOroms(),
|
||||
}
|
||||
case "SetBootstrapToken":
|
||||
pbc := pb.GetSetBootstrapToken()
|
||||
cmd.SetBootstrapToken = &SetBootstrapToken{
|
||||
BootstrapToken: pbc.GetBootstrapToken(),
|
||||
}
|
||||
case "VerifyFirmwarePassword":
|
||||
pbc := pb.GetVerifyFirmwarePassword()
|
||||
cmd.VerifyFirmwarePassword = &VerifyFirmwarePassword{
|
||||
|
||||
12
tools/api/commands/set_bootstrap_token
Executable file
12
tools/api/commands/set_bootstrap_token
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
source $MICROMDM_ENV_PATH
|
||||
endpoint="v1/commands"
|
||||
jq -n \
|
||||
--arg request_type "SetBootstrapToken" \
|
||||
--arg udid "$1" \
|
||||
--arg token "$2" \
|
||||
'.udid = $udid
|
||||
|.request_type = $request_type
|
||||
|.bootstrap_token = $token
|
||||
'|\
|
||||
curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@-
|
||||
Reference in New Issue
Block a user