Documentation
¶
Index ¶
- Constants
- func HTTPGatewayComposeService(files HTTPGatewayFiles, spec HTTPGatewaySpec) string
- func LoopbackHTTPSURL(port int) (string, error)
- func NewHTTPClient(material TLSMaterial, requireClient bool) (*http.Client, error)
- func NewHTTPClientForPolicy(material TLSMaterial, policy Policy) (*http.Client, error)
- func NewHTTPClientWithBasicAuth(material TLSMaterial, username, password string) (*http.Client, error)
- func RetireTLSOverlap(ctx context.Context, issuer Issuer, policy Policy, dir string) error
- func TCPGatewayComposeService(files TCPGatewayFiles, spec TCPGatewaySpec) string
- func VerifyBrowserRoute(ctx context.Context, client *http.Client, rawURL string) error
- func VerifyBrowserRouteWithAllowedAuthorities(ctx context.Context, client *http.Client, rawURL string, allowedURLs ...string) error
- func VerifyBrowserSurface(ctx context.Context, client *http.Client, rawURL string) error
- func VerifyBrowserSurfaceWithAllowedAuthorities(ctx context.Context, client *http.Client, rawURL string, allowedURLs ...string) error
- func WaitHTTPS(ctx context.Context, client *http.Client, endpoint, path string) error
- type AuthenticationMode
- type CertificateRequest
- type HTTPGatewayFiles
- type HTTPGatewaySpec
- type IssuedCertificate
- type Issuer
- type IssuerStatus
- type LifecycleObservation
- type NativeTLSFiles
- type PKISource
- type Policy
- type TCPGatewayFiles
- type TCPGatewaySpec
- type TCPGatewayUpstream
- type TLSMaterial
- type TrustBundle
Constants ¶
const ( EnvPKISource = "BASEHARBOR_SERVICE_PKI_SOURCE" EnvTLSCertFile = "BASEHARBOR_SERVICE_TLS_CERT_FILE" EnvTLSKeyFile = "BASEHARBOR_SERVICE_TLS_KEY_FILE" EnvTrustBundle = "BASEHARBOR_SERVICE_TLS_TRUST_FILE" EnvClientCertFile = "BASEHARBOR_SERVICE_TLS_CLIENT_CERT_FILE" EnvClientKeyFile = "BASEHARBOR_SERVICE_TLS_CLIENT_KEY_FILE" EnvIssuerRef = "BASEHARBOR_SERVICE_PKI_ISSUER_REF" EnvServerName = "BASEHARBOR_SERVICE_TLS_SERVER_NAME" EnvAuthentication = "BASEHARBOR_SERVICE_AUTHENTICATION" EnvAuthTokenFile = "BASEHARBOR_SERVICE_AUTH_TOKEN_FILE" )
const GatewayImage = "docker.io/library/caddy:2.11.4-alpine"
const TCPGatewayImage = "docker.io/library/haproxy:3.2.23-alpine"
Variables ¶
This section is empty.
Functions ¶
func HTTPGatewayComposeService ¶
func HTTPGatewayComposeService(files HTTPGatewayFiles, spec HTTPGatewaySpec) string
func LoopbackHTTPSURL ¶
func NewHTTPClient ¶
func NewHTTPClient(material TLSMaterial, requireClient bool) (*http.Client, error)
func NewHTTPClientForPolicy ¶
func NewHTTPClientForPolicy(material TLSMaterial, policy Policy) (*http.Client, error)
func NewHTTPClientWithBasicAuth ¶ added in v0.4.17
func NewHTTPClientWithBasicAuth(material TLSMaterial, username, password string) (*http.Client, error)
func RetireTLSOverlap ¶ added in v0.4.21
RetireTLSOverlap removes a previous CA only after the provider has verified the newly issued server/client leaves through its stable service endpoint. It is idempotent so a verified retirement can be retried safely.
func TCPGatewayComposeService ¶
func TCPGatewayComposeService(files TCPGatewayFiles, spec TCPGatewaySpec) string
func VerifyBrowserRoute ¶ added in v0.4.18
VerifyBrowserRoute validates bounded same-authority redirects while preserving route-level reachability semantics for surfaces that intentionally answer with authentication challenges.
func VerifyBrowserRouteWithAllowedAuthorities ¶ added in v0.4.18
func VerifyBrowserSurface ¶ added in v0.4.18
VerifyBrowserSurface validates a user-facing HTTPS URL the way a browser would reach it, while keeping redirect traversal bounded to the same effective authority. A non-default port therefore cannot silently collapse to HTTPS/443 during a redirect.
func VerifyBrowserSurfaceWithAllowedAuthorities ¶ added in v0.4.18
func VerifyBrowserSurfaceWithAllowedAuthorities(ctx context.Context, client *http.Client, rawURL string, allowedURLs ...string) error
VerifyBrowserSurfaceWithAllowedAuthorities permits only the canonical URL plus explicitly listed HTTPS authorities. It is intended for products such as Keycloak where an admin alias may redirect to the canonical identity host.
Types ¶
type AuthenticationMode ¶
type AuthenticationMode string
const ( AuthenticationNone AuthenticationMode = "none" AuthenticationNative AuthenticationMode = "native" AuthenticationMTLS AuthenticationMode = "mtls" AuthenticationToken AuthenticationMode = "token" AuthenticationOIDC AuthenticationMode = "oidc" AuthenticationOAuth2 AuthenticationMode = "oauth2" AuthenticationExternal AuthenticationMode = "external" )
type CertificateRequest ¶
type HTTPGatewayFiles ¶
type HTTPGatewayFiles struct {
Dir string
Caddyfile string
Material TLSMaterial
AuthToken string
HealthAuthorizationEnv string
}
func EnsureHTTPGateway ¶
func EnsureHTTPGateway(ctx context.Context, issuer Issuer, policy Policy, providerDir string, spec HTTPGatewaySpec) (HTTPGatewayFiles, error)
type HTTPGatewaySpec ¶
type HTTPGatewaySpec struct {
ServiceName string
Upstream string
Upstreams []string
UpstreamTrustFile string
UpstreamServerName string
UpstreamClientCertificate string
UpstreamClientKey string
PublishedPortEnv string
ContainerPort int
Networks []string
NetworkAliases []string
CertificateNames []string
RequireClient bool
DenyPaths []string
BasicAuthUsername string
BasicAuthPassword string
HealthURI string
HealthStatus int
HealthAuthorizationEnv string
}
type IssuedCertificate ¶
type Issuer ¶
type Issuer interface {
TrustBundle(ctx context.Context) (TrustBundle, error)
Issue(ctx context.Context, request CertificateRequest) (IssuedCertificate, error)
Renew(ctx context.Context, current IssuedCertificate, request CertificateRequest) (IssuedCertificate, error)
Revoke(ctx context.Context, serial string) error
Status(ctx context.Context) (IssuerStatus, error)
}
Issuer is the provider-neutral certificate authority boundary used by service access. Implementations own issuer state and lifecycle; callers only receive the leaf material and public trust required for the selected runtime.
type IssuerStatus ¶
type LifecycleObservation ¶
type LifecycleObservation struct {
Source PKISource `json:"source"`
LifecycleOwner string `json:"lifecycle_owner"`
RenewalMode string `json:"renewal_mode"`
IssuerReference string `json:"issuer_reference,omitempty"`
ServerExpiresAt time.Time `json:"server_expires_at"`
ClientExpiresAt time.Time `json:"client_expires_at,omitempty"`
Health string `json:"health"`
Warning string `json:"warning,omitempty"`
}
LifecycleObservation is the secret-safe, provider-neutral certificate lifecycle state exposed to status/doctor/evidence surfaces.
func InspectLifecycle ¶
func InspectLifecycle(dir string) (LifecycleObservation, error)
InspectLifecycle reads already-materialized lifecycle state. It never issues, renews, revokes or otherwise mutates certificate material.
type NativeTLSFiles ¶ added in v0.4.17
type NativeTLSFiles struct {
Dir string
Material TLSMaterial
}
func EnsureNativeTLS ¶ added in v0.4.17
type Policy ¶
type Policy struct {
Environment string `json:"environment"`
Provider string `json:"provider"`
TLSRequired bool `json:"tls_required"`
AuthenticationRequired bool `json:"authentication_required"`
Authentication AuthenticationMode `json:"authentication"`
PKISource PKISource `json:"pki_source"`
ServerName string `json:"server_name,omitempty"`
ServerCertificate string `json:"server_certificate,omitempty"`
ServerKey string `json:"server_key,omitempty"`
TrustBundle string `json:"trust_bundle,omitempty"`
ClientCertificate string `json:"client_certificate,omitempty"`
ClientKey string `json:"client_key,omitempty"`
IssuerReference string `json:"issuer_reference,omitempty"`
AuthTokenFile string `json:"auth_token_file,omitempty"`
}
type TCPGatewayFiles ¶
type TCPGatewayFiles struct {
Dir string
Config string
PEM string
Material TLSMaterial
}
func EnsureTCPGateway ¶
func EnsureTCPGateway(ctx context.Context, issuer Issuer, policy Policy, providerDir string, spec TCPGatewaySpec) (TCPGatewayFiles, error)
type TCPGatewaySpec ¶
type TCPGatewayUpstream ¶ added in v0.4.21
type TLSMaterial ¶
type TLSMaterial struct {
Source PKISource `json:"source"`
CA string `json:"ca"`
ServerCertificate string `json:"server_certificate"`
ServerKey string `json:"server_key"`
ClientCertificate string `json:"client_certificate,omitempty"`
ClientKey string `json:"client_key,omitempty"`
ServerName string `json:"server_name"`
}
func EnsureTLSMaterial ¶
func ExistingTLSMaterial ¶
func ExistingTLSMaterial(policy Policy, dir string) (TLSMaterial, error)