endpoints

package
v1.53.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ClientConfigSuffix = "-clientconfig"

ClientConfigSuffix ends the name of every Secret holding a user's session credential.

Variables

This section is empty.

Functions

func SecretName added in v1.32.0

func SecretName(username string) string

SecretName names the Secret holding username's session credential, as authn writes it and every consumer reads it: the username made DNS-1123 compatible, plus ClientConfigSuffix. It is the one definition of that name; compute it here rather than rebuilding it, since a near-miss names a Secret that doesn't exist.

func Store

func Store(ctx context.Context, rc *rest.Config, ns string, ep Endpoint) error

Store writes ep as username's credential Secret in ns: a create, or an update when the Secret exists.

Types

type Endpoint

type Endpoint struct {
	ServerURL                string `json:"serverURL"`
	ProxyURL                 string `json:"proxyURL,omitempty"`
	CertificateAuthorityData string `json:"caData,omitempty"`
	ClientCertificateData    string `json:"-"`
	ClientKeyData            string `json:"-"`
	Token                    string `json:"token,omitempty"`
	Username                 string `json:"username,omitempty"`
	Password                 string `json:"password,omitempty"`
	Debug                    bool   `json:"debug"`
	Insecure                 bool   `json:"insecure"`
	// PassCredentialsOnRedirect lets a credential follow a redirect to a DIFFERENT host:port
	// (core-provider#307). Default false, which refuses.
	//
	// NAMED FOR THE HOP, not for the destination, deliberately. helm's equivalent is
	// PassCredentialsAll, and an operator reads "all" as a statement about which destinations are
	// allowed rather than about every hop of a chain they never see. The installer session made
	// exactly that point about an allowAnyHost flag elsewhere: the people who set such a flag are
	// by definition debugging something, and they are the least likely to be thinking about
	// redirects.
	//
	// IT REMOVES THE WHOLE GUARD, not part of it. With this set, a credential will follow a 302
	// anywhere the endpoint sends it - including a subdomain, a different port, or an unrelated
	// host. There is no partial setting and that is on purpose: a half-guard would be harder to
	// reason about than none.
	//
	// It exists because the strict default has a legitimate casualty: an endpoint configured
	// without a port that redirects to one - an on-prem GHES, or a corporate proxy - is a real
	// deployment, and helm's own chart getter has carried PassCredentialsAll for that reason since
	// long before this. Measured on krateo-057: 0 of 3 external targets issue any 3xx, so nothing
	// there needs it; the field is for the deployment that does.
	PassCredentialsOnRedirect bool `json:"passCredentialsOnRedirect,omitempty"`
	// AWS garbage fields for their proprietary authentication header
	AwsAccessKey string `json:"awsAccessKey"`
	AwsSecretKey string `json:"awsSecretKey"`
	AwsRegion    string `json:"awsRegion"`
	AwsService   string `json:"awsService"`
	// AWS time field, testing only
	AwsTime string `json:"awsTime"`
}

func FromSecret

func FromSecret(ctx context.Context, rc *rest.Config, name, namespace string) (Endpoint, error)

func (*Endpoint) HasAwsAuth

func (ep *Endpoint) HasAwsAuth() bool

HasAwsAuth returns whether the configuration has AWS authentication or not.

ALL FOUR SigV4 INPUTS, and the fourth term used to be a DUPLICATE of AwsSecretKey rather than AwsService — so this reported "has AWS auth" for a configuration that cannot produce a valid signature. `A && A` is `A`, so the typo was invisible until go 1.26's vet made "redundant and" an error and the package stopped building.

Why AwsService is the missing term and not a guess: ComputeAwsSignature uses it twice, in the credential scope and in the signing-key derivation (http/request/util.go:146, :158). With it empty, the scope reads ".../<region>//aws4_request" and the key is derived over an empty service, so AWS answers SignatureDoesNotMatch. Returning true for that is a false positive about the one thing the predicate exists to decide.

THE BEHAVIOUR CHANGE, stated rather than buried — three call sites, all in http/request:

access+secret+region+service          signs, works                  unchanged
access+secret+region, NO service      signed with an EMPTY service   -> now unsigned,
                                      and rejected by AWS               failing visibly
the same, PLUS a bearer token         countTrue==2, so client.go      -> countTrue==1,
                                      REFUSES the request outright       the token is used

No configuration that works today stops working. The third row is the one worth noticing: an endpoint whose bearer token is complete is refused today because incomplete AWS fields sit beside it, and that request starts succeeding.

func (*Endpoint) HasBasicAuth

func (ep *Endpoint) HasBasicAuth() bool

HasBasicAuth returns whether the configuration has basic authentication or not.

func (*Endpoint) HasCA

func (ep *Endpoint) HasCA() bool

HasCA returns whether the configuration has a certificate authority or not.

func (*Endpoint) HasCertAuth

func (ep *Endpoint) HasCertAuth() bool

HasCertAuth returns whether the configuration has certificate authentication or not.

func (*Endpoint) HasTokenAuth

func (ep *Endpoint) HasTokenAuth() bool

HasTokenAuth returns whether the configuration has token authentication or not.

type Written added in v1.43.0

type Written struct {
	Namespace string
	Name      string
	// UID and ResourceVersion are the stored Secret's; empty when nothing was
	// stored, or when the apiserver's answer to a successful write couldn't be
	// decoded.
	UID             string
	ResourceVersion string
	// Verb is "create" or "update": the request that stored the Secret, or the
	// one that failed.
	Verb string
	// StatusCode is the apiserver's HTTP status for that request, 0 when no
	// response arrived.
	StatusCode int
}

Written is what Store wrote: the Secret, the verb of the request that stored it, and the apiserver's answer to that request. An audit record names the object written and the verb sent (AUDIT-4), and neither can be inferred afterwards: Store's create is answered 409 when the Secret exists, and the update that follows is the write. Names only, never data.

func StoreWritten added in v1.43.0

func StoreWritten(ctx context.Context, rc *rest.Config, ns string, ep Endpoint) (Written, error)

StoreWritten is Store, reporting what it wrote. On an error, Written still names the Secret and, when a request was sent, its verb and status.

Jump to

Keyboard shortcuts

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