api

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	APIEndpointPushCert        = "/pushcert"
	APIEndpointPush            = "/push/"    // note trailing slash
	APIEndpointEnqueue         = "/enqueue/" // note trailing slash
	APIEndpointEscrowKeyUnlock = "/escrowkeyunlock"
)

Variables

This section is empty.

Functions

func HandleAPIv1 added in v0.8.0

func HandleAPIv1(prefix string, mux Mux, logger log.Logger, store APIStorage, pusher push.Pusher)

HandleAPIv1 registers the various API handlers into mux. API endpoint paths are prepended with prefix. Authentication or any other layered handlers are not present. They are assumed to be layered with mux. If prefix is empty and these handlers are used in sub-paths then handlers should have that sub-path stripped from the request. The logger is adorned with a "handler" key of the endpoint name.

func NewEscrowKeyUnlockHandler added in v0.9.0

func NewEscrowKeyUnlockHandler(store storage.PushCertStore, client *http.Client, logger log.Logger) http.HandlerFunc

NewEscrowKeyUnlockHandler creates an Escrow Key Unlock (i.e. Activation Lock Bypass) handler. The handler takes in all parameters in the HTTP post form and splits them between the required form and URL query parameters for Apple. APNs keypairs are read for store. The default HTTP client will be used if client is nil.

func NewStorePushCertHandler added in v0.9.0

func NewStorePushCertHandler(storage storage.PushCertStorer, logger log.Logger) http.HandlerFunc

NewStorePushCertHandler reads a PEM-encoded certificate and private key from the HTTP body and saves it to storage. This effectively enables us to do something like: `% cat push.pem push.key | curl -T - http://example.com:9001/v1/pushcert` to upload our MDM APNs push cert.

func PathIDGetter added in v0.8.0

func PathIDGetter(r *http.Request) ([]string, error)

PathIDGetter returns the list of comma-separated enrollment IDs from r.

func PushHandler deprecated

func PushHandler(pusher push.Pusher, logger log.Logger) http.HandlerFunc

PushHandler sends APNs push notifications to MDM enrollments.

Note the whole URL path is used as the identifier to push to. This probably necessitates stripping the URL prefix before using. Also note we expose Go errors to the output as this is meant for "API" users.

Deprecated: use PushToIDsHandler instead. Use PathIDGetter with it for the previous behavior.

func PushToIDsHandler added in v0.8.0

func PushToIDsHandler(pusher push.Pusher, logger log.Logger, idGetter func(*http.Request) ([]string, error)) http.HandlerFunc

PushToIDsHandler sends APNs push notifications to MDM enrollments. Use idGetter to get the slice of enrollment IDs from the HTTP request.

func RawCommandEnqueueHandler deprecated

func RawCommandEnqueueHandler(enqueuer storage.CommandEnqueuer, pusher push.Pusher, logger log.Logger) http.HandlerFunc

RawCommandEnqueueHandler enqueues a raw MDM command plist and sends push notifications to MDM enrollments.

Note the whole URL path is used as the identifier to enqueue (and push to. This probably necessitates stripping the URL prefix before using. Also note we expose Go errors to the output as this is meant for "API" users.

Deprecated: use RawCommandEnqueueToIDsHandler instead. Use PathIDGetter with it for the previous behavior.

func RawCommandEnqueueToIDsHandler added in v0.8.0

func RawCommandEnqueueToIDsHandler(enqueuer storage.CommandEnqueuer, pusher push.Pusher, logger log.Logger, idGetter func(*http.Request) ([]string, error)) http.HandlerFunc

RawCommandEnqueueToIDsHandler enqueues a raw MDM command and sends push notifications to MDM enrollments. Use idGetter to get the slice of enrollment IDs from the HTTP request.

Types

type APIStorage added in v0.8.0

APIStorage is required for the API handlers.

type ErrorResponseJson added in v0.9.0

type ErrorResponseJson struct {
	// Error response string.
	Error string `json:"error"`
}

Error response.

type Mux added in v0.8.0

type Mux interface {
	// Handle registers the handler for the given pattern.
	// It is assumed pattern operates similar to http.ServeMux with
	// respect to "trailing slash" behavior.
	Handle(pattern string, handler http.Handler)
}

Mux can register HTTP handlers.

type PushCertResponseJson added in v0.9.0

type PushCertResponseJson struct {
	// Expiration date of the uploaded APNs certificate.
	NotAfter time.Time `json:"not_after"`

	// The "topic" (UID attribute) from the uploaded APNs certificate.
	Topic string `json:"topic"`
}

APNs push certificate and key upload response.

Jump to

Keyboard shortcuts

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