mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-11 20:45:32 +08:00
add auto setup admin accounts changes
This commit is contained in:
5
tools/api/commands/account_configuration_managed_user
Executable file
5
tools/api/commands/account_configuration_managed_user
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
source $MICROMDM_ENV_PATH
|
||||
endpoint="v1/commands"
|
||||
go run ./tools/api/commands/account_configuration_managed_user.go | jq --arg udid "$1" '. + {udid: $udid}' | curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@-
|
||||
|
||||
58
tools/api/commands/account_configuration_managed_user.go
Normal file
58
tools/api/commands/account_configuration_managed_user.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/groob/plist"
|
||||
"github.com/micromdm/micromdm/mdm/mdm"
|
||||
"github.com/micromdm/micromdm/pkg/crypto/password"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
flPassword = flag.String("password", "groob", "Password of the user. Only required when creating a new user.")
|
||||
)
|
||||
flag.Parse()
|
||||
|
||||
salted, err := password.SaltedSHA512PBKDF2(*flPassword)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
hashDict := struct {
|
||||
SaltedSHA512PBKDF2 password.SaltedSHA512PBKDF2Dictionary `plist:"SALTED-SHA512-PBKDF2"`
|
||||
}{
|
||||
SaltedSHA512PBKDF2: salted,
|
||||
}
|
||||
|
||||
hashPlist, err := plist.Marshal(hashDict)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
cmd := &mdm.CommandRequest{
|
||||
Command: &mdm.Command{
|
||||
RequestType: "AccountConfiguration",
|
||||
AccountConfiguration: &mdm.AccountConfiguration{
|
||||
SkipPrimarySetupAccountCreation: true,
|
||||
ManagedLocalUserShortName: "groob",
|
||||
AutoSetupAdminAccounts: []mdm.AdminAccount{
|
||||
{
|
||||
ShortName: "groob",
|
||||
FullName: "Victor Vrantchan",
|
||||
PasswordHash: hashPlist,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
out, err := json.MarshalIndent(cmd, "", " ")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(string(out))
|
||||
}
|
||||
20
tools/api/commands/set_auto_admin_password
Executable file
20
tools/api/commands/set_auto_admin_password
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# populate and lock the account info for the setup assistant.
|
||||
# Example:
|
||||
# ./tools/api/commands/account_configuration_populate_user $udid "Full Name" "username"
|
||||
#
|
||||
source $MICROMDM_ENV_PATH
|
||||
endpoint="v1/commands"
|
||||
hashPlist="$(go run ./tools/api/commands/account_configuration_managed_user.go | jq .auto_setup_admin_accounts[0].password_hash -r)"
|
||||
jq -n \
|
||||
--arg request_type "SetAutoAdminPassword" \
|
||||
--arg udid "$1" \
|
||||
--arg guid "$2" \
|
||||
--arg hashPlist "$hashPlist" \
|
||||
'.udid = $udid
|
||||
|.guid = $guid
|
||||
|.password_hash = $hashPlist
|
||||
|.request_type = $request_type
|
||||
'|\
|
||||
curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@-
|
||||
|
||||
10
tools/api/commands/user_list
Executable file
10
tools/api/commands/user_list
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
source $MICROMDM_ENV_PATH
|
||||
endpoint="v1/commands"
|
||||
jq -n \
|
||||
--arg request_type "UserList" \
|
||||
--arg udid "$1" \
|
||||
'.udid = $udid
|
||||
|.request_type = $request_type
|
||||
'|\
|
||||
curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@-
|
||||
Reference in New Issue
Block a user