proxywire

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package proxywire defines the internal protocol between separately deployed MDM and declaration-engine roles.

Design

POST /v1/declarative-management carries the original DeclarativeManagement check-in plist. Versioned request HMACs bind method, target, content type, timestamp, nonce and body. Response HMACs bind the request envelope, status, content type and body. Verification checks five-minute freshness and atomically claims nonces in a caller-supplied shared store for ten minutes. Shared helpers apply body limits and signature encoding. Proxyserver can additionally require mutual TLS or another authorization check.

This is a project-specific deployment protocol, not an Apple or NanoMDM transport contract. The adapters resolve enrollment from the forwarded message. HMAC does not encrypt data; the adapters require HTTPS, with an explicit literal-loopback exception for tests. Replicas must share replay state.

References

Index

Constants

View Source
const (
	// Path is the only route the ddm role serves for the mdm role.
	Path = "/v1/declarative-management"
	// ContentType is the request body type: the check-in plist as received.
	ContentType = "application/x-apple-aspen-mdm-checkin"
	// HeaderSignature carries base64(HMAC-SHA256(key, ...)): the body on a
	// request, and the status with the body on a response.
	HeaderSignature = "X-MDM-Signature"
	// DefaultMaxBody bounds request and response bodies (1 MiB).
	DefaultMaxBody = 1 << 20
)

Wire constants.

Variables

View Source
var (
	ErrMissingSignature = errors.New("proxywire: missing signature")
	ErrBadSignature     = errors.New("proxywire: bad signature")
	ErrBodyTooLarge     = errors.New("proxywire: body too large")
	ErrContentType      = errors.New("proxywire: unexpected content type")
)

Errors.

Functions

func ReadBody

func ReadBody(r io.Reader, limit int64) ([]byte, error)

ReadBody reads at most limit bytes from r; a longer body is ErrBodyTooLarge. A non-positive limit means DefaultMaxBody.

func Sign

func Sign(key, body []byte) string

Sign returns the header value for a request body under key. A request is the whole message, so the body is the whole of what needs covering.

func SignBoundResponse

func SignBoundResponse(key []byte, request string, status int, ct string, body []byte) string

SignBoundResponse binds a response to this request and its exact representation.

func SignRequest

func SignRequest(key []byte, r *http.Request, body []byte) (string, error)

SignRequest creates a fresh v2 envelope covering the method, target and body.

func SignResponse

func SignResponse(key []byte, status int, body []byte) string

SignResponse authenticates status and body together. Covering status prevents an authenticated empty error body from being replayed as a declaration-removal 404. Content type is excluded because the adapter does not use it for authorization decisions.

func ValidKeys

func ValidKeys(send, recv []byte) bool

ValidKeys requires independent keys with at least 256 bits of key material.

func Verify

func Verify(key []byte, header string, body []byte) error

Verify checks header against a request body under key. A missing header is ErrMissingSignature; anything that does not match is ErrBadSignature.

func VerifyBoundResponse

func VerifyBoundResponse(
	key []byte,
	header, request string,
	status int,
	ct string,
	body []byte,
) error

VerifyBoundResponse rejects response substitution, including another request's response.

func VerifyRequest

func VerifyRequest(
	ctx context.Context,
	st state.Store,
	key []byte,
	r *http.Request,
	body []byte,
) error

VerifyRequest authenticates freshness and atomically claims the nonce before effects.

func VerifyResponse

func VerifyResponse(key []byte, header string, status int, body []byte) error

VerifyResponse checks header against a response carrying body under status.

Types

This section is empty.

Jump to

Keyboard shortcuts

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