Documentation
¶
Index ¶
- Constants
- func Wrap(prefix string, err error) error
- type Ensurer
- type Error
- type Fallback
- type KeyManager
- func (m *KeyManager) DeleteAll() error
- func (m *KeyManager) GetGitHubPAT() (string, error)
- func (m *KeyManager) GetHMACSecret() (string, error)
- func (m *KeyManager) IsConfigured() bool
- func (m *KeyManager) RotateGitHubPAT(newPAT string) error
- func (m *KeyManager) RotateHMACSecret(newSecret string) error
- func (m *KeyManager) SetLog(fn func(...any))
- func (m *KeyManager) Setup(hmacSecret, githubPAT string) error
- type Keyring
- type Provider
Constants ¶
const ( ServiceName = "updater-cicd" HMACSecretKey = "hmac-secret" GitHubPATKey = "github-pat" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Ensurer ¶ added in v0.2.0
Ensurer is implemented by backends that can repair their own prerequisites (install packages, start a daemon). NewKeyring calls it when the initial probe fails. Backends that cannot self-repair simply do not implement it.
type Error ¶ added in v0.2.0
type Error string
Error is the error type of this package. It is a comparable string so callers can use errors.Is / == without this package importing "errors".
const ( // ErrNotFound is returned when the key has no value in this service. ErrNotFound Error = "keyring: secret not found" // ErrUnsupported is returned by the fallback backend on platforms with no // credential store. ErrUnsupported Error = "keyring: no credential store on this platform" // ErrTooBig is returned when the value exceeds the backend's limit. ErrTooBig Error = "keyring: value too large for the platform credential store" // (no D-Bus session, locked keychain, storage blocked by the browser). ErrUnavailable Error = "keyring: credential store unavailable" // ErrNoProvider is returned when a Keyring is built with a nil provider. ErrNoProvider Error = "keyring: no provider injected" )
type Fallback ¶ added in v0.2.0
type Fallback struct{}
Fallback answers every call with ErrUnsupported. It is what auto.Provider() returns on platforms with no credential store.
type KeyManager ¶ added in v0.0.2
type KeyManager struct {
// contains filtered or unexported fields
}
KeyManager manages the service-exposed secrets (HMAC secret, GitHub PAT) of ServiceName on top of a generic Keyring. Same API as before; now backed by the shared Keyring type.
func New ¶
func New(p Provider) *KeyManager
New creates a KeyManager over the ServiceName service with provider p.
func (*KeyManager) DeleteAll ¶ added in v0.0.2
func (m *KeyManager) DeleteAll() error
DeleteAll elimina todos los secretos (reset)
func (*KeyManager) GetGitHubPAT ¶ added in v0.0.2
func (m *KeyManager) GetGitHubPAT() (string, error)
GetGitHubPAT obtiene el GitHub PAT
func (*KeyManager) GetHMACSecret ¶ added in v0.0.2
func (m *KeyManager) GetHMACSecret() (string, error)
GetHMACSecret obtiene el HMAC secret
func (*KeyManager) IsConfigured ¶ added in v0.0.2
func (m *KeyManager) IsConfigured() bool
IsConfigured verifica si están configurados
func (*KeyManager) RotateGitHubPAT ¶ added in v0.0.2
func (m *KeyManager) RotateGitHubPAT(newPAT string) error
RotateGitHubPAT rota el GitHub PAT
func (*KeyManager) RotateHMACSecret ¶ added in v0.0.2
func (m *KeyManager) RotateHMACSecret(newSecret string) error
RotateHMACSecret rota el HMAC secret
func (*KeyManager) SetLog ¶ added in v0.0.2
func (m *KeyManager) SetLog(fn func(...any))
SetLog sets the logging function.
func (*KeyManager) Setup ¶ added in v0.0.2
func (m *KeyManager) Setup(hmacSecret, githubPAT string) error
Setup realiza el setup inicial - solo primera ejecución
type Keyring ¶
type Keyring struct {
// contains filtered or unexported fields
}
Keyring provides scoped credential storage through an injected backend. The service name is a namespace: the same key under different services never collides, so one process can hold secrets for several apps.
func NewKeyring ¶ added in v0.0.2
NewKeyring creates a Keyring scoped to service over provider p, and verifies the backend actually works — asking it to repair itself when it implements Ensurer.
Callers that do not care which backend they get can use github.com/tinywasm/keyring/auto, which picks one for the target platform.
func OpenKeyring ¶ added in v0.0.3
OpenKeyring creates a Keyring without probing the backend: nothing is touched until the first Get/Set/Delete. Use it when the store is only needed conditionally (session recovery) or in flows that may legitimately run without one (CI with GH_TOKEN).
func (*Keyring) Get ¶ added in v0.0.2
Get returns the value stored under key in this service's namespace.
type Provider ¶ added in v0.0.2
type Provider interface {
// Set stores password for user under service.
Set(service, user, password string) error
// Get returns the password stored for user under service.
Get(service, user string) (string, error)
// Delete removes the password stored for user under service.
Delete(service, user string) error
// DeleteAll removes every entry under service.
DeleteAll(service string) error
}
Provider abstracts the OS keyring backend (Secret Service, Keychain, Credential Manager).