callbackurl

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package callbackurl validates and constructs the static callback URL boundary shared by providerd configuration and callback builders.

Index

Constants

View Source
const (
	// ProvisionPath is the only backend callback ingress path.
	ProvisionPath = "/callbacks/provision"
)

Variables

This section is empty.

Functions

func ValidateRawQuery

func ValidateRawQuery(rawQuery string) error

ValidateRawQuery restricts an already-escaped wire representation to RFC 3986 query characters. net/url intentionally treats RawQuery as opaque: it will place a raw space, backslash, or non-UTF-8 byte directly in an HTTP/1 request line instead of escaping it. Different servers and proxies can then reject or rewrite bytes that the callback HMAC signed. Percent-encoded forms remain valid and byte-preserving; url.ParseQuery above proves every percent triplet is complete and rejects Go's unsupported raw semicolon separator.

Types

type Base

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

Base is a validated, canonical callback URL base. Its zero value is invalid; ParseBase is the only constructor. The parsed URL is private so callers cannot accidentally mutate validated authority into a different destination.

func ParseBase

func ParseBase(raw string) (Base, error)

ParseBase validates and canonicalizes a callback base while preserving its RawQuery byte-for-byte. Path spelling is canonicalized before HMAC-bound URLs are built: trailing separators are removed and RawPath is cleared so equivalent escapes and literal Unicode have one RequestURI representation.

func (Base) EscapedPath

func (base Base) EscapedPath() string

EscapedPath returns the canonical path bytes that an HTTP request will carry. It is the value a path-stripping verifier prefix must match byte-for-byte.

func (Base) ProvisionURL

func (base Base) ProvisionURL() (*url.URL, error)

ProvisionURL returns an independent URL value with ProvisionPath appended. The returned copy may be given one typed query capability by the provisioner; mutating it cannot invalidate Base itself.

func (Base) String

func (base Base) String() string

String returns the normalized base URL, or the empty string for an invalid zero value. RawQuery is emitted exactly as supplied to ParseBase.

type Endpoint

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

Endpoint is an immutable, wire-stable HTTP callback destination. ParseEndpoint is its only constructor; keeping url.URL private prevents callers from mutating a validated destination before it is persisted or sent.

func ParseEndpoint

func ParseEndpoint(raw string) (Endpoint, error)

ParseEndpoint validates a complete callback destination without rewriting it. In particular, Path and RawQuery must already be in the exact form that net/http will put in RequestURI, because callback authentication signs those bytes and durable queues must be able to replay them unchanged.

func (Endpoint) EscapedPath

func (endpoint Endpoint) EscapedPath() string

EscapedPath returns the exact path bytes carried by RequestURI.

func (Endpoint) Hostname

func (endpoint Endpoint) Hostname() string

Hostname returns the validated hostname without brackets or port.

func (Endpoint) RawQuery

func (endpoint Endpoint) RawQuery() string

RawQuery returns the exact query bytes carried by RequestURI.

func (Endpoint) String

func (endpoint Endpoint) String() string

String returns the exact validated destination, or the empty string for an invalid zero value.

func (Endpoint) WithRawQuery

func (endpoint Endpoint) WithRawQuery(rawQuery string) (string, error)

WithRawQuery returns the same validated destination with a replacement wire-stable query. It is used only to exchange typed callback capabilities while preserving the already-proved authority and path.

Jump to

Keyboard shortcuts

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