api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package api implements HTTP handlers for the NanoDEP API.

Index

Constants

This section is empty.

Variables

View Source
var CKMismatch = errors.New("mismatched consumer key")

Functions

func DecryptTokenPKIHandler

func DecryptTokenPKIHandler(store TokenPKIRetriever, tokenStore AuthTokensStore, logger log.Logger) http.HandlerFunc

DecryptTokenPKIHandler reads the Apple-provided encrypted token ".p7m" file from the request body and decrypts it with the keypair generated from GetCertTokenPKIHandler.

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

func GetCertTokenPKIHandler

func GetCertTokenPKIHandler(store TokenPKIStorer, logger log.Logger) http.HandlerFunc

GetCertTokenPKIHandler generates a new private key and certificate for the token PKI exchange with the ABM/ASM/BE portal. Every call to this handler generates a new keypair and stores it. The PEM-encoded certificate is returned.

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

func PEMRSAPrivateKey

func PEMRSAPrivateKey(key *rsa.PrivateKey) []byte

PEMRSAPrivateKey returns key as a PEM block.

func RetrieveAssignerProfileHandler

func RetrieveAssignerProfileHandler(store sync.AssignerProfileRetriever, logger log.Logger) http.HandlerFunc

RetrieveAssignerProfileHandler returns the assigner profile UUID for the given DEP name.

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

func RetrieveAuthTokensHandler

func RetrieveAuthTokensHandler(store client.AuthTokensRetriever, logger log.Logger) http.HandlerFunc

RetrieveAuthTokensHandler returns the DEP server OAuth1 tokens for the DEP name in the path.

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

func RetrieveConfigHandler

func RetrieveConfigHandler(store client.ConfigRetriever, logger log.Logger) http.HandlerFunc

RetrieveConfigHandler returns the DEP server config for the DEP name in the path.

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

func StoreAssignerProfileHandler

func StoreAssignerProfileHandler(store AssignerProfileStorer, logger log.Logger) http.HandlerFunc

StoreAssignerProfileHandler saves the assigner profile UUID for the given DEP name.

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

func StoreAuthTokensHandler

func StoreAuthTokensHandler(store AuthTokensStore, logger log.Logger) http.HandlerFunc

StoreAuthTokensHandler reads DEP server OAuth1 tokens as a JSON body and saves them using store.

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

func StoreConfigHandler

func StoreConfigHandler(store ConfigStorer, logger log.Logger) http.HandlerFunc

StoreConfigHandler stores the DEP server config for the DEP name in the path.

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

Types

type AssignerProfileStorer

type AssignerProfileStorer interface {
	StoreAssignerProfile(ctx context.Context, name string, profileUUID string) error
}

type AuthTokensStore added in v0.1.1

type AuthTokensStore interface {
	client.AuthTokensRetriever
	AuthTokensStorer
}

type AuthTokensStorer

type AuthTokensStorer interface {
	StoreAuthTokens(ctx context.Context, name string, tokens *client.OAuth1Tokens) error
}

type ConfigStorer

type ConfigStorer interface {
	StoreConfig(ctx context.Context, name string, config *client.Config) error
}

type TokenPKIRetriever

type TokenPKIRetriever interface {
	RetrieveTokenPKI(ctx context.Context, name string) (pemCert []byte, pemKey []byte, err error)
}

type TokenPKIStorer

type TokenPKIStorer interface {
	StoreTokenPKI(ctx context.Context, name string, pemCert []byte, pemKey []byte) error
}

Jump to

Keyboard shortcuts

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