Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BWProvider ¶
type BWProvider struct {
// contains filtered or unexported fields
}
BWProvider wraps BWClient to implement the Provider interface. URI parsing is handled here so that callers only see the generic Resolve(uri) method.
func NewBWProvider ¶
func NewBWProvider(client *bw.BWClient) *BWProvider
NewBWProvider creates a BWProvider backed by the given BWClient.
func (*BWProvider) Client ¶
func (p *BWProvider) Client() *bw.BWClient
Client returns the underlying BWClient. Use this only when you need access to BW-specific operations (e.g. FolderItems) that are not part of the Provider interface.
func (*BWProvider) Close ¶
func (p *BWProvider) Close() error
Close zeros the in-process BW session token.
func (*BWProvider) Resolve ¶
func (p *BWProvider) Resolve(uri string) (string, error)
Resolve parses the bw:// URI and delegates to the underlying BWClient.
func (*BWProvider) Schemes ¶
func (p *BWProvider) Schemes() []string
Schemes returns ["bw"] — the URI scheme handled by this provider.
type Provider ¶
type Provider interface {
// Schemes returns the URI schemes this provider handles, e.g. ["bw"].
Schemes() []string
// Resolve fetches the secret identified by the full URI string (e.g. "bw://folder/item")
// and returns its plaintext value.
// URI parsing and validation are the responsibility of the provider.
Resolve(uri string) (string, error)
// Close releases any in-process resources (sessions, tokens).
// It must be safe to call multiple times.
Close() error
}
Provider is the extension point for secret backends. Each backend implements this interface and registers itself with a Registry so callers never need to import concrete client types.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry routes secret URIs to the correct Provider by URI scheme. Build one registry at startup and pass it to all callers instead of threading concrete provider types throughout the codebase.
Usage:
reg := providers.NewRegistry()
reg.Register(providers.NewBWProvider(bwClient))
value, err := reg.Resolve("bw://folder/item")
func (*Registry) Close ¶
Close calls Close on every registered provider exactly once. If a provider is registered for multiple schemes it is still closed only once. A non-nil error from one provider does not stop the others from being closed. The last non-nil error is returned.
func (*Registry) IsSecretRef ¶
IsSecretRef returns true if uri uses a scheme registered with this registry.
func (*Registry) ProviderFor ¶
ProviderFor returns the provider registered for the given scheme. The second return value is false if no provider is registered.