Documentation
¶
Index ¶
- Variables
- type APIError
- type Client
- func (c *Client) Authenticate(ctx context.Context) error
- func (c *Client) Do(ctx context.Context, method, path string, requestBody any, responseBody any) error
- func (c *Client) Get(ctx context.Context, path string, responseBody any) error
- func (c *Client) GetDecryptedSecretByID(ctx context.Context, itemID string) (Secret, error)
- func (c *Client) GetSecretByID(ctx context.Context, itemID string) (Secret, error)
- func (c *Client) ListDecryptedSecrets(ctx context.Context) ([]Secret, error)
- func (c *Client) ListDecryptedSecretsByOrganization(ctx context.Context, organizationID string) ([]Secret, error)
- func (c *Client) ListSecrets(ctx context.Context) ([]Secret, error)
- func (c *Client) ListSecretsByOrganization(ctx context.Context, organizationID string) ([]Secret, error)
- func (c *Client) Post(ctx context.Context, path string, requestBody any, responseBody any) error
- type Config
- type Option
- type Secret
- type Token
Constants ¶
This section is empty.
Variables ¶
var ErrSecretNotFound = errors.New("secret not found")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a reusable Vaultwarden API client with token caching.
func (*Client) Authenticate ¶
Authenticate obtains and caches a valid token.
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, method, path string, requestBody any, responseBody any) error
Do sends a JSON request with bearer authentication.
func (*Client) GetDecryptedSecretByID ¶
GetDecryptedSecretByID returns one decrypted secret by item ID.
func (*Client) GetSecretByID ¶
GetSecretByID returns one raw secret by item ID.
func (*Client) ListDecryptedSecrets ¶
ListDecryptedSecrets fetches sync data and decrypts secret fields with the master password.
func (*Client) ListDecryptedSecretsByOrganization ¶
func (c *Client) ListDecryptedSecretsByOrganization(ctx context.Context, organizationID string) ([]Secret, error)
ListDecryptedSecretsByOrganization returns decrypted secrets filtered by organization ID.
func (*Client) ListSecrets ¶
ListSecrets fetches and normalizes secrets from the default Vaultwarden sync endpoint.
type Config ¶
type Config struct {
BaseURL string
TokenEndpoint string
ClientID string
ClientSecret string
MasterPassword string
Username string
Password string
Scope string
GrantType string
DeviceIdentifier string
DeviceName string
DeviceType string
Timeout time.Duration
}
Config contains connector settings for Vaultwarden authentication and API calls.
func LoadConfigFromEnv ¶
LoadConfigFromEnv loads connector configuration from environment variables.
type Option ¶
Option configures client initialization.
func WithHTTPClient ¶
WithHTTPClient injects a custom HTTP client.
type Secret ¶
type Secret struct {
ID string `json:"id"`
Name string `json:"name"`
OrganizationID string `json:"organization_id,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
TOTP string `json:"totp,omitempty"`
TOTPCode string `json:"totp_code,omitempty"`
SSHPublicKey string `json:"ssh_public_key,omitempty"`
SSHPrivateKey string `json:"ssh_private_key,omitempty"`
SSHFingerprint string `json:"ssh_fingerprint,omitempty"`
CardholderName string `json:"cardholder_name,omitempty"`
CardBrand string `json:"card_brand,omitempty"`
CardNumber string `json:"card_number,omitempty"`
CardExpMonth string `json:"card_exp_month,omitempty"`
CardExpYear string `json:"card_exp_year,omitempty"`
CardCode string `json:"card_code,omitempty"`
Notes string `json:"notes,omitempty"`
Fields map[string]string `json:"fields,omitempty"`
}
Secret represents a normalized secret extracted from Vaultwarden sync data.