Documentation
¶
Overview ¶
Package auth models Bitbucket credentials, resolves them from configuration or secure storage, and applies them to outgoing HTTP requests.
Index ¶
Constants ¶
const ( SchemePAT = "pat" // Bearer Personal Access Token (Data Center 7.9+) SchemeBasic = "basic" // HTTP Basic (DC: user+password; Cloud: email+API token) )
Scheme identifies an authentication scheme.
const ( BackendKeychain = "keychain" BackendFile = "file" )
Backend names reported by Save.
Variables ¶
var ErrSecretNotFound = errors.New("secret not found")
ErrSecretNotFound is returned by a Store when no secret exists for an account.
Functions ¶
func AccountKey ¶
AccountKey derives the keychain account identifier for a base URL and scheme. It is stable across runs so credentials can be located later.
Types ¶
type Credential ¶
type Credential struct {
Scheme string
Username string // basic only
Secret string // PAT token, or password / API token
}
Credential is a fully resolved credential ready to authenticate requests.
func Resolve ¶
Resolve produces a Credential from configuration. A secret supplied via flags/env/.env (carried in secrets) takes precedence; otherwise the secret is loaded from the Store. The returned credential is validated.
func (Credential) Decorator ¶
func (c Credential) Decorator() transport.Decorator
Decorator returns a transport.Decorator that authenticates every request.
func (Credential) Header ¶
func (c Credential) Header() string
Header returns the Authorization header value for the credential.
func (Credential) Redacted ¶
func (c Credential) Redacted() Credential
Redacted returns a copy safe for logging: the secret is masked.
func (Credential) Validate ¶
func (c Credential) Validate() error
Validate reports whether the credential is internally consistent.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists secrets. It prefers the OS keychain and transparently falls back to a protected file under the config directory when the keychain is unavailable. Windows encrypts the fallback with per-user DPAPI; other platforms retain the existing 0600 file behavior.
func (*Store) Delete ¶
Delete removes the secret for account from both backends. Missing entries are not an error.
type StoreAccessError ¶ added in v0.12.0
StoreAccessError means the credential store could not be inspected. It is intentionally distinct from ErrSecretNotFound: a caller must not tell the user to reconfigure credentials when a sandbox merely hid the keychain.
func (*StoreAccessError) Error ¶ added in v0.12.0
func (e *StoreAccessError) Error() string
func (*StoreAccessError) Unwrap ¶ added in v0.12.0
func (e *StoreAccessError) Unwrap() error