Documentation
¶
Overview ¶
Package credential defines shared upstream authentication and metadata.
Index ¶
Constants ¶
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 ¶
type BYOK ¶
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 ¶
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
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.