header

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DeviceInfoHeader = "x-apple-aspen-deviceinfo"

Variables

View Source
var (
	ErrEmptyHeader      = errors.New("empty header")
	ErrNotSigned        = errors.New("not signed")
	ErrCertRootNotFound = errors.New("certificate root not found")
)
View Source
var AppleRootCert = newAppleRootCert()

AppleRootCert is Apple's Root CA parsed to an *x509.Certificate

View Source
var DefaultParser = NewParser(WithVerify(true))

Functions

This section is empty.

Types

type Context

type Context map[string]any

type InvalidHeaderError

type InvalidHeaderError struct {
	Err error
}

func (*InvalidHeaderError) Error

func (e *InvalidHeaderError) Error() string

func (*InvalidHeaderError) Unwrap

func (e *InvalidHeaderError) Unwrap() error

type MachineInfo

type MachineInfo struct {
	IMEI     string `plist:"IMEI,omitempty"`
	Language string `plist:"LANGUAGE,omitempty"`
	MEID     string `plist:"MEID,omitempty"`
	Product  string `plist:"PRODUCT"`
	Serial   string `plist:"SERIAL"`
	UDID     string `plist:"UDID"`
	Version  string `plist:"VERSION"`

	// VerifyContext is optionally populated by VerifyFuncs set on the Parser.
	// Parser.Parse guarantees VerifyContext to be non-nil
	VerifyContext Context `plist:"-"`
}

MachineInfo is a device's information sent as part of an MDM enrollment profile request

type Parser

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

Parser parses the x-apple-aspen-deviceinfo header from requests sent to the configuration_web_url as part of the Authenticating Through Web Views enrollment process

func NewParser

func NewParser(opts ...ParserOption) *Parser

func (*Parser) Parse

func (p *Parser) Parse(r *http.Request) (*MachineInfo, error)

Parse parses the x-apple-aspen-deviceinfo header from the request, verifies the request as configured by the Parser, and returns the parsed *MachineInfo

type ParserOption

type ParserOption func(p *Parser)

func WithVerify

func WithVerify(verify bool) ParserOption

WithVerify configures the parser to verify the signature against the Apple Root CA if verify is true

func WithVerifyFunc

func WithVerifyFunc(f VerifyFunc) ParserOption

WithVerifyFunc configures the parser with a custom verify function that is run after other verifications take place. Multiple VerifyFuncs can be used, and they're executed in the order they're configured. If f returns an error, verification fails when Parse is called, and the error is returned. See VerifyFunc for more information

type VerifyFunc

type VerifyFunc func(r *http.Request, p7 *pkcs7.PKCS7, ctx Context) error

VerifyFunc is used to add additional verification of the initial device request. The original request, r, verified PKCS7 header, p7, and additional context, ctx are passed to the function. ctx is passed through the chain of VerifyFuncs, with the final result being added to the *MachineInfo returned by the parser. ctx should not be modified outside of the scope of the function.

Jump to

Keyboard shortcuts

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