add auto setup admin accounts changes

This commit is contained in:
Victor Vrantchan
2020-06-24 02:45:37 +00:00
parent 0a67a21103
commit 08a4e80c30
10 changed files with 389 additions and 240 deletions

View 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@-

View 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))
}

View 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
View 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@-