foss

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package foss implements communication with with Free/Open Source MDM servers.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoIDsInIDChunk = errors.New("no ids in id chunk")

Functions

func WebhookHandler

func WebhookHandler(recv MDMEventReceiver, logger log.Logger) http.HandlerFunc

WebhookHandler parses the F/OSS MDM webhook callback for hand-off for futher processing.

Types

type AcknowledgeEvent

type AcknowledgeEvent struct {
	UDID         string            `json:"udid,omitempty"`
	EnrollmentID string            `json:"enrollment_id,omitempty"`
	Status       string            `json:"status"`
	CommandUUID  string            `json:"command_uuid,omitempty"`
	Params       map[string]string `json:"url_params,omitempty"`
	RawPayload   []byte            `json:"raw_payload"`
}

type CheckinEvent

type CheckinEvent struct {
	UDID         string            `json:"udid,omitempty"`
	EnrollmentID string            `json:"enrollment_id,omitempty"`
	Params       map[string]string `json:"url_params"`
	RawPayload   []byte            `json:"raw_payload"`

	// signals which tokenupdate this is to be able to tell whether this
	// is the initial enrollment vs. a following tokenupdate
	TokenUpdateTally *int `json:"token_update_tally,omitempty"`
}

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer executes an HTTP request.

type Event

type Event struct {
	Topic     string    `json:"topic"`
	EventID   string    `json:"event_id"`
	CreatedAt time.Time `json:"created_at"`

	AcknowledgeEvent *AcknowledgeEvent `json:"acknowledge_event,omitempty"`
	CheckinEvent     *CheckinEvent     `json:"checkin_event,omitempty"`
}

type FossMDM

type FossMDM struct {
	// contains filtered or unexported fields
}

FossMDM sends requests to Free/Open Source MDM servers for enqueueing MDM commands and sending APNs pushes. Ostensibly this means NanoMDM and MicroMDM servers, but any server that supports compatible API endpoints could work, too.

func NewFossMDM

func NewFossMDM(enqRef, apiKey string, opts ...Option) (*FossMDM, error)

NewFossMDM creates a new FossMDM. The enqueue and push URL "base" is specified with enqRef. By default we target NanoMDM conventions.

func (*FossMDM) Enqueue

func (m *FossMDM) Enqueue(ctx context.Context, ids []string, rawCommand []byte) error

Enqueue sends the HTTP request to enqueue rawCommand to ids on the MDM server.

func (*FossMDM) Push

func (m *FossMDM) Push(ctx context.Context, ids []string) error

Push sends the HTTP request to send APNs pushes to ids on the MDM server.

func (*FossMDM) SupportsMultiCommands

func (m *FossMDM) SupportsMultiCommands() bool

SupportsMultiCommands reports whether we support multi-targeted commands. These are commands that can be sent to multiple devices (i.e. using the same UUID).

type MDMCheckinEventer

type MDMCheckinEventer interface {
	MDMCheckinEvent(ctx context.Context, id string, checkin interface{}, mdmContext *workflow.MDMContext) error
}

type MDMCommandResponseEventer

type MDMCommandResponseEventer interface {
	MDMCommandResponseEvent(ctx context.Context, id string, uuid string, raw []byte, mdmContext *workflow.MDMContext) error

	// MDMIdleEvent is called when an MDM Report Results has an "Idle" status.
	MDMIdleEvent(ctx context.Context, id string, raw []byte, mdmContext *workflow.MDMContext, eventAt time.Time) error
}

type MDMEventDumper

type MDMEventDumper struct {
	// contains filtered or unexported fields
}

MDMEventDumper is an MDM eventer middleware that dumps command responses to an output writer.

func NewMDMEventDumper

func NewMDMEventDumper(next MDMEventReceiver, output io.Writer) *MDMEventDumper

func (*MDMEventDumper) MDMCheckinEvent

func (d *MDMEventDumper) MDMCheckinEvent(ctx context.Context, id string, checkin interface{}, mdmContext *workflow.MDMContext) error

MDMCheckinEvent processes the next eventer.

func (*MDMEventDumper) MDMCommandResponseEvent

func (d *MDMEventDumper) MDMCommandResponseEvent(ctx context.Context, id string, uuid string, raw []byte, mdmContext *workflow.MDMContext) error

MDMCommandResponseEvent dumps the raw command response and processes the next eventer.

func (*MDMEventDumper) MDMIdleEvent added in v0.3.0

func (d *MDMEventDumper) MDMIdleEvent(ctx context.Context, id string, raw []byte, mdmContext *workflow.MDMContext, eventAt time.Time) error

MDMIdleEvent is called when an MDM Report Results has an "Idle" status.

type MDMEventReceiver

type MDMEventReceiver interface {
	MDMCommandResponseEventer
	MDMCheckinEventer
}

type Option

type Option func(*FossMDM) error

func WithLogger

func WithLogger(logger log.Logger) Option

func WithMicroMDM

func WithMicroMDM() Option

WithMicroMDM uses MicroMDM API conventions.

func WithPush

func WithPush(ref string) Option

WithPush configures sending APNs push requests to ref base URL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL