Documentation
¶
Overview ¶
Package http includes handlers and utilties
Index ¶
- func CertExtractMdmSignatureMiddleware(next http.Handler, logger log.Logger) http.HandlerFunc
- func CertExtractPEMHeaderMiddleware(next http.Handler, header string, logger log.Logger) http.HandlerFunc
- func CertExtractTLSMiddleware(next http.Handler, logger log.Logger) http.HandlerFunc
- func CertVerifyMiddleware(next http.Handler, verifier CertVerifier, logger log.Logger) http.HandlerFunc
- func CheckinAndCommandHandlerFunc(service service.CheckinAndCommandService, logger log.Logger) http.HandlerFunc
- func CheckinHandlerFunc(svc service.Checkin, logger log.Logger) http.HandlerFunc
- func CommandAndReportResultsHandlerFunc(svc service.CommandAndReportResults, logger log.Logger) http.HandlerFunc
- func GetCert(ctx context.Context) *x509.Certificate
- func PushHandlerFunc(pusher push.Pusher, logger log.Logger) http.HandlerFunc
- func RawCommandEnqueueHandler(enqueuer storage.CommandEnqueuer, pusher push.Pusher, logger log.Logger) http.HandlerFunc
- func ReadAllAndReplaceBody(r *http.Request) ([]byte, error)
- func StorePushCertHandlerFunc(storage storage.PushCertStore, logger log.Logger) http.HandlerFunc
- type CertVerifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CertExtractMdmSignatureMiddleware ¶
CertExtractMdmSignatureMiddleware extracts the MDM enrollment identity certificate from the request into the HTTP request context. It tries to verify the Mdm-Signature header on the request.
This middleware does not error if a certificate is not found. It will, however, error with an HTTP 400 status if the signature verification fails.
func CertExtractPEMHeaderMiddleware ¶
func CertExtractPEMHeaderMiddleware(next http.Handler, header string, logger log.Logger) http.HandlerFunc
CertExtractPEMHeaderMiddleware extracts the MDM enrollment identity certificate from the request into the HTTP request context. It looks at the request header which should be a URL-encoded PEM certificate.
This is ostensibly to support Nginx' $ssl_client_escaped_cert in a proxy_set_header directive. Though any reverse proxy setting a similar header could be used, of course.
func CertExtractTLSMiddleware ¶
CertExtractTLSMiddleware extracts the MDM enrollment identity certificate from the request into the HTTP request context. It looks at the TLS peer certificate in the request.
func CertVerifyMiddleware ¶
func CertVerifyMiddleware(next http.Handler, verifier CertVerifier, logger log.Logger) http.HandlerFunc
CertVerifyMiddleware checks the MDM certificate against verifier and returns an error if it fails.
We deliberately do not reply with 401 as this may cause unintentional MDM unenrollments in the case of bugs or something going wrong.
func CheckinAndCommandHandlerFunc ¶
func CheckinAndCommandHandlerFunc(service service.CheckinAndCommandService, logger log.Logger) http.HandlerFunc
CheckinAndCommandHandlerFunc handles both check-in and command requests.
func CheckinHandlerFunc ¶
CheckinHandlerFunc decodes an MDM check-in request and adapts it to service.
func CommandAndReportResultsHandlerFunc ¶
func CommandAndReportResultsHandlerFunc(svc service.CommandAndReportResults, logger log.Logger) http.HandlerFunc
CommandAndReportResultsHandlerFunc decodes an MDM command request and adapts it to service.
func GetCert ¶
func GetCert(ctx context.Context) *x509.Certificate
GetCert retrieves the MDM enrollment identity certificate from the HTTP request context.
func PushHandlerFunc ¶
PushHandlerFunc 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.
func RawCommandEnqueueHandler ¶
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.
func ReadAllAndReplaceBody ¶
ReadAllAndReplaceBody reads all of r.Body and replaces it with a new byte buffer.
func StorePushCertHandlerFunc ¶
func StorePushCertHandlerFunc(storage storage.PushCertStore, logger log.Logger) http.HandlerFunc
StorePushCertHandlerFunc 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://api.example.com/" to upload our push certs.
Types ¶
type CertVerifier ¶
type CertVerifier interface {
Verify(*x509.Certificate) error
}
CertVerifier is a simple interface for verifying a certificate.