routeservice

package
v0.0.0-...-7097cd0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 1 more Imports: 8 Imported by: 15

Documentation

Index

Constants

View Source
const (
	HeaderKeySignature    = "X-CF-Proxy-Signature"
	HeaderKeyForwardedURL = "X-CF-Forwarded-Url"
	HeaderKeyMetadata     = "X-CF-Proxy-Metadata"
)

Variables

View Source
var ErrExpired = errors.New("route service request expired")

Functions

func BuildSignatureAndMetadata

func BuildSignatureAndMetadata(
	crypto secure.Crypto,
	signatureContents *SignatureContents,
) (string, string, error)

Types

type Metadata

type Metadata struct {
	Nonce []byte `json:"nonce"`
}

type RequestReceivedFromRouteService

type RequestReceivedFromRouteService struct {
	Metadata  string
	Signature string
	AppUrl    string
}

type RequestToSendToRouteService

type RequestToSendToRouteService struct {
	URLString      string
	ParsedUrl      *url.URL
	Signature      string
	Metadata       string
	ForwardedURL   string
	RecommendHttps bool
}

type RouteServiceConfig

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

func NewRouteServiceConfig

func NewRouteServiceConfig(
	logger *slog.Logger,
	enabled bool,
	hairpinning bool,
	hairpinningAllowlist []string,
	timeout time.Duration,
	crypto secure.Crypto,
	cryptoPrev secure.Crypto,
	recommendHttps bool,
	strictSignatureValidation bool,
) *RouteServiceConfig

func (*RouteServiceConfig) CreateRequest

func (rs *RouteServiceConfig) CreateRequest(rsUrl, forwardedUrl string) (RequestToSendToRouteService, error)

func (*RouteServiceConfig) RouteServiceEnabled

func (rs *RouteServiceConfig) RouteServiceEnabled() bool

func (*RouteServiceConfig) RouteServiceHairpinning

func (rs *RouteServiceConfig) RouteServiceHairpinning() bool

func (*RouteServiceConfig) RouteServiceHairpinningAllowlist

func (rs *RouteServiceConfig) RouteServiceHairpinningAllowlist() []string

func (*RouteServiceConfig) RouteServiceRecommendHttps

func (rs *RouteServiceConfig) RouteServiceRecommendHttps() bool

func (*RouteServiceConfig) StrictSignatureValidation

func (rs *RouteServiceConfig) StrictSignatureValidation() bool

func (*RouteServiceConfig) ValidateRequest

type SignatureContents

type SignatureContents struct {
	ForwardedUrl  string    `json:"forwarded_url"`
	RequestedTime time.Time `json:"requested_time"`
}

func SignatureContentsFromHeaders

func SignatureContentsFromHeaders(signatureHeader, metadataHeader string, crypto secure.Crypto) (SignatureContents, error)

Jump to

Keyboard shortcuts

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