credential

package
v2.39.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package credential defines shared upstream authentication and metadata.

Index

Constants

View Source
const (
	// KindCentralized identifies provider-managed credentials.
	KindCentralized Kind = "centralized"
	// KindBYOK identifies user-supplied provider credentials.
	KindBYOK Kind = "byok"

	// Hint placeholders for credentials with no static key value to mask.
	// Hints are persisted to aibridge_interceptions.credential_hint, a VARCHAR(15),
	// so every value here must be at most 15 characters.
	// HintFailoverKey is used before a centralized key is selected.
	HintFailoverKey = "<failover key>" //nolint:gosec // Placeholder, not a credential.
	// HintAWSChainKey identifies credentials resolved through the AWS default chain.
	HintAWSChainKey = "<aws chain>"
)

Variables

This section is empty.

Functions

func WithCredentialInfo

func WithCredentialInfo(ctx context.Context, cred Credential) context.Context

WithCredentialInfo returns a context carrying the credential hint and length.

Types

type AWSSigV4

type AWSSigV4 struct {
	AccessKey string
}

AWSSigV4 authenticates with AWS SigV4 request signing: requests are signed (so there is no auth header) using either static credentials (when an access key is set) or the AWS default credential chain. There is no key pool or failover. It covers every AWS-signed upstream, not just Bedrock.

func (AWSSigV4) AuthHeader

func (AWSSigV4) AuthHeader() string

func (AWSSigV4) Hint

func (c AWSSigV4) Hint() string

func (AWSSigV4) Kind

func (AWSSigV4) Kind() Kind

func (AWSSigV4) Length

func (c AWSSigV4) Length() int

type BYOK

type BYOK struct {
	Secret string
	Header string
}

BYOK authenticates with a single user-supplied secret.

func AsBYOK

func AsBYOK(c Credential) (BYOK, bool)

AsBYOK reports whether c is a BYOK credential and returns it if so.

func (BYOK) AuthHeader

func (b BYOK) AuthHeader() string

func (BYOK) Hint

func (b BYOK) Hint() string

func (BYOK) Kind

func (BYOK) Kind() Kind

func (BYOK) Length

func (b BYOK) Length() int

type CentralizedPool

type CentralizedPool struct {
	Pool   *keypool.Pool
	Header string
	// contains filtered or unexported fields
}

CentralizedPool authenticates with a provider-managed key pool and fails over across keys.

func AsCentralizedPool

func AsCentralizedPool(c Credential) (*CentralizedPool, bool)

AsCentralizedPool reports whether c is a key-pool credential that fails over, and returns it if so.

func (*CentralizedPool) AuthHeader

func (c *CentralizedPool) AuthHeader() string

func (*CentralizedPool) Hint

func (c *CentralizedPool) Hint() string

func (*CentralizedPool) Kind

func (*CentralizedPool) Kind() Kind

func (*CentralizedPool) Length

func (c *CentralizedPool) Length() int

func (*CentralizedPool) NextKey

func (c *CentralizedPool) NextKey(w *keypool.Walker) (*keypool.Key, *keypool.Error)

NextKey advances the failover walker and records the selected key as the one in use.

type Credential

type Credential interface {
	Kind() Kind
	// AuthHeader is the header carrying this request's credential, or empty when
	// the credential is not carried in a header.
	AuthHeader() string
	// Hint is a masked, identifiable fragment of the credential.
	Hint() string
	// Length is the length of the credential value.
	Length() int
}

Credential is the per-request upstream authentication:

  • BYOK: a user-supplied secret.
  • AWSSigV4: AWS credentials, used to sign requests.
  • CentralizedPool: a provider-managed key pool with failover.

type Kind

type Kind string

Kind identifies how a request was authenticated. Values must match the credential_kind enum in coderd's database.

Jump to

Keyboard shortcuts

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