Documentation
¶
Overview ¶
Package domainconnect holds the install side of the Domain Connect sync flow (ADR 091). It never holds a signing key: the signer service does.
Index ¶
- Constants
- Variables
- func AppendSignature(unsigned, sig, key string) string
- func BuildApplyURL(p ApplyParams) (string, error)
- func BuildSignerURL(r SignerRequest) (string, error)
- func DraftTemplate(serviceID string) (map[string]any, error)
- func NewNonce() (string, error)
- func NormalizeDomain(raw string) (string, error)
- func ParseReturnURL(raw string) (*url.URL, string, error)
- func SignState(key []byte, origin, domain, nonce string, ttl time.Duration, now time.Time) (string, error)
- func SignedPayload(unsigned string) string
- func ZoneCandidates(domain string) ([]string, error)
- type ApplyParams
- type Claims
- type Config
- type Discoverer
- type Discovery
- type Fetcher
- type SignerRequest
Constants ¶
const ( KindApp = "app" KindPreview = "preview" )
Record kinds a flow can apply.
Variables ¶
var ( ErrBlockedAddress = errors.New("domainconnect: address is not allowed") ErrTooLarge = errors.New("domainconnect: response is too large") ErrRedirect = errors.New("domainconnect: redirects are not followed") ErrBadURL = errors.New("domainconnect: url must be https with a host name") )
Errors returned by the guarded fetcher.
var ( ErrBadState = errors.New("domainconnect: state is not valid") ErrStateExpired = errors.New("domainconnect: state has expired") ErrStateOrigin = errors.New("domainconnect: state belongs to another origin") ErrReturnURL = errors.New("domainconnect: return url is not allowed") )
Errors returned by state and return URL checks.
var ( ErrNotSupported = errors.New("domainconnect: no Domain Connect provider found for this domain") ErrNotHosted = errors.New("domainconnect: the provider does not host this zone") ErrBadSettings = errors.New("domainconnect: provider settings are not usable") ErrBadInput = errors.New("domainconnect: invalid input") )
Errors returned by discovery and input validation.
Functions ¶
func AppendSignature ¶
AppendSignature adds sig and key as the last parameters, as providers require.
func BuildApplyURL ¶
func BuildApplyURL(p ApplyParams) (string, error)
BuildApplyURL returns the unsigned apply URL with a fixed key order: domain, host, redirect_uri, state, groupId, then variables sorted by name.
func BuildSignerURL ¶
func BuildSignerURL(r SignerRequest) (string, error)
BuildSignerURL returns the signer start URL for the browser to open.
func DraftTemplate ¶
DraftTemplate returns the parsed draft for a service id.
func NormalizeDomain ¶
NormalizeDomain lowercases and validates a public DNS name with at least two labels.
func ParseReturnURL ¶
ParseReturnURL accepts an https URL, or http on exactly localhost or 127.0.0.1 with any port, with no credentials. It returns the URL and its origin.
func SignState ¶
func SignState(key []byte, origin, domain, nonce string, ttl time.Duration, now time.Time) (string, error)
SignState returns payload.mac, both base64url, valid until now+ttl.
func SignedPayload ¶
SignedPayload returns the query string that is signed: everything after the question mark.
func ZoneCandidates ¶
ZoneCandidates lists the names to try for the zone root, longest first, ending at the registrable domain (public suffix plus one label).
Types ¶
type ApplyParams ¶
type ApplyParams struct {
URLSyncUX string
ProviderID string
ServiceID string
Domain string // zone root
Host string // below the root, empty for the root
RedirectURI string
State string
GroupID string
Variables map[string]string
}
ApplyParams are the parts of a sync apply URL before signing.
type Claims ¶
type Claims struct {
Origin string `json:"o"`
Domain string `json:"d"`
Nonce string `json:"n"`
Expiry int64 `json:"e"`
}
Claims is what the flow token binds. The key comes from the install's existing derived-key facility (secrets.Manager.DeriveKey with a purpose string), so no new secret store exists.
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
Discoverer finds the Domain Connect provider of a domain.
func NewDiscoverer ¶
func NewDiscoverer(cfg Config) (*Discoverer, error)
NewDiscoverer builds a Discoverer from the domainconnect.* setting values.
type Discovery ¶
type Discovery struct {
Domain string `json:"domain"`
Zone string `json:"zone"`
Host string `json:"host"`
ProviderID string `json:"provider_id"`
ProviderName string `json:"provider_name"`
URLSyncUX string `json:"url_sync_ux"`
URLAPI string `json:"url_api"`
SyncAvailable bool `json:"sync_available"`
}
Discovery is the answer for one domain. Zone is the root the provider hosts, Host is the part of the domain below it (empty for the root itself).
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher does GET requests that can only reach public addresses.
func NewFetcher ¶
NewFetcher needs both limits from settings; there are no built-in defaults.