Documentation
¶
Index ¶
- Constants
- Variables
- func BodyDigest(body []byte) string
- func Canonical(fields ...string) []byte
- func CertificateIdentity(certPEM []byte) (string, error)
- func LoadMaterial(certDir string) (*Verifier, *Responder, error)
- func Middleware(verifier *Verifier, responder *Responder, maxBodyBytes int64, ...) echo.MiddlewareFunc
- func ReadBody(req *http.Request, limit int64) ([]byte, error)
- func RequestBase(audience, method, target, contentType, bodyDigest string, timestamp int64, ...) []byte
- func ResponseBase(requestNonce string, status int, contentType string, bodyDigest string, ...) []byte
- func SessionFor(c echo.Context, direction string) (*FrameWriter, *FrameReader, error)
- func SessionKey(local *ecdsa.PrivateKey, remote *ecdsa.PublicKey, salt string) ([]byte, error)
- func SignResponses(responder *Responder) echo.MiddlewareFunc
- func SignUpgradeResponses(responder *Responder) echo.MiddlewareFunc
- func VerifyBody(req *http.Request, body []byte) error
- type BodyWriter
- type FrameReader
- type FrameWriter
- type Responder
- type Verifier
Constants ¶
View Source
const ( HeaderSignature = "X-Berth-Signature" HeaderCertificate = "X-Berth-Certificate" HeaderTimestamp = "X-Berth-Timestamp" HeaderNonce = "X-Berth-Nonce" HeaderBodyDigest = "X-Berth-Body-Digest" RequestContext = "berth-request-v1" ResponseContext = "berth-response-v1" ServerIdentity = "berth-server" BodyUnsigned = "unsigned" BodyFramed = "framed" FrameBodyBeyond = 1024 * 1024 )
View Source
const ( AuthorityFileName = "ca.crt" CertificateFileName = "agent.crt" KeyFileName = "agent.key" DefaultSkew = time.Minute )
View Source
const ( StreamContext = "berth-stream-v1" DirectionToAgent = "to-agent" DirectionToBerth = "to-berth" DirectionBodyToBerth = "body-to-berth" )
Variables ¶
View Source
var ErrFrameRejected = errors.New("stream frame rejected")
View Source
var ErrRejected = errors.New("request signature rejected")
Functions ¶
func BodyDigest ¶
func CertificateIdentity ¶
func Middleware ¶
func RequestBase ¶
func ResponseBase ¶
func SessionFor ¶
func SessionFor(c echo.Context, direction string) (*FrameWriter, *FrameReader, error)
func SessionKey ¶
func SignResponses ¶
func SignResponses(responder *Responder) echo.MiddlewareFunc
func SignUpgradeResponses ¶
func SignUpgradeResponses(responder *Responder) echo.MiddlewareFunc
Types ¶
type BodyWriter ¶
type BodyWriter struct {
// contains filtered or unexported fields
}
func NewBodyWriter ¶
func NewBodyWriter(writer io.Writer, key []byte) *BodyWriter
func (*BodyWriter) Close ¶
func (w *BodyWriter) Close() error
type FrameReader ¶
type FrameReader struct {
// contains filtered or unexported fields
}
func NewFrameReader ¶
func NewFrameReader(key []byte, direction string) *FrameReader
func (*FrameReader) UnwrapTyped ¶
func (r *FrameReader) UnwrapTyped(frame []byte) (byte, []byte, error)
type FrameWriter ¶
type FrameWriter struct {
// contains filtered or unexported fields
}
func NewFrameWriter ¶
func NewFrameWriter(key []byte, direction string) *FrameWriter
func (*FrameWriter) Wrap ¶
func (w *FrameWriter) Wrap(payload []byte) []byte
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
func NewResponder ¶
func (*Responder) SessionKeyFor ¶
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
func NewVerifier ¶
func (*Verifier) VerifyRequest ¶
Click to show internal directories.
Click to hide internal directories.