client

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client is a Secret Service client for lys components that keep a secret of their own in the user's keyring, such as the portal's per-app master secrets. It works against any provider on the bus (lys-secrets or gnome-keyring), over a plain session: the secret never leaves the user's own bus.

Index

Constants

View Source
const LoginCollection = dbus.ObjectPath("/org/freedesktop/secrets/collection/login")

LoginCollection is the collection the login password opens, under lys-secrets and gnome-keyring alike.

Variables

View Source
var ErrDismissed = errors.New("secrets: the prompt was dismissed")

ErrDismissed is the user (or the client) dismissing a prompt.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is one plain session with the Secret Service.

func Open

func Open(ctx context.Context, conn *dbus.Conn) (*Client, error)

Open starts a session; without a provider on the bus it fails.

func OpenEncrypted

func OpenEncrypted(ctx context.Context, conn *dbus.Conn) (*Client, error)

OpenEncrypted starts a DH session, so secrets cross the bus encrypted under a key only this client and the provider hold.

func (*Client) ChangeLock

func (c *Client) ChangeLock(ctx context.Context, coll dbus.ObjectPath) error

ChangeLock asks the provider for a new password for coll through its prompt (lys-secrets' extension of the service).

func (*Client) Close

func (c *Client) Close()

Close ends the session.

func (*Client) Collections

func (c *Client) Collections(ctx context.Context) ([]Collection, error)

Collections is every collection the provider serves.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, attrs map[string]string) error

func (*Client) DeleteItem

func (c *Client) DeleteItem(ctx context.Context, item dbus.ObjectPath) error

DeleteItem deletes the item, through a prompt when the provider asks.

func (*Client) Describe

func (c *Client) Describe(ctx context.Context, items []dbus.ObjectPath) ([]Item, error)

Describe is the items' labels, attributes, times and lock state, their GetAll calls sent together and collected after.

func (*Client) Find

func (c *Client) Find(ctx context.Context, attrs map[string]string) (value []byte, found bool, err error)

Find finds the first unlocked item holding attrs and returns its secret, asking nothing; found is false when no unlocked item matches.

func (*Client) Lock

func (c *Client) Lock(ctx context.Context, objects []dbus.ObjectPath) error

Lock locks objects.

func (*Client) Lookup

func (c *Client) Lookup(ctx context.Context, attrs map[string]string) (value []byte, found bool, err error)

Lookup finds the first item holding attrs and returns its secret, unlocking its collection through a prompt when it is locked. found is false when no item matches.

func (*Client) Search

func (c *Client) Search(ctx context.Context, coll dbus.ObjectPath) ([]dbus.ObjectPath, error)

Search is every item of coll, locked or not.

func (*Client) Secret

func (c *Client) Secret(ctx context.Context, item dbus.ObjectPath) ([]byte, error)

Secret is the item's secret, its collection unlocked through the provider's prompt when needed. The caller owns the returned bytes and should clear them when done.

func (*Client) SetLabel

func (c *Client) SetLabel(ctx context.Context, item dbus.ObjectPath, label string) error

SetLabel renames the item.

func (*Client) SetSecret

func (c *Client) SetSecret(ctx context.Context, item dbus.ObjectPath, value []byte, contentType string) error

SetSecret replaces the item's secret.

func (*Client) Store

func (c *Client) Store(ctx context.Context, label string, attrs map[string]string, value []byte) error

Store saves value under attrs in the default collection, replacing an item with the same attributes; a missing default collection is created through the provider's prompt.

func (*Client) StoreLogin

func (c *Client) StoreLogin(ctx context.Context, label string, attrs map[string]string, value []byte) error

StoreLogin saves value under attrs in the login collection, replacing an item with the same attributes, unlocking it through a prompt when it is locked.

func (*Client) Unlock

func (c *Client) Unlock(ctx context.Context, objects []dbus.ObjectPath) error

Unlock unlocks objects (collections or items) through the provider's prompt when it needs one.

func (*Client) WatchItems

func (c *Client) WatchItems(ctx context.Context, coll dbus.ObjectPath, changed func(), failed func(error)) (*dbusx.Watch, error)

WatchItems runs changed, on the watch's goroutine, on every item created, changed or deleted in coll that the provider owning the Secret Service's name announces, until ctx ends or the watch is stopped. failed is told, on the same goroutine, of such an announcement that did not decode.

type Collection

type Collection struct {
	Path   dbus.ObjectPath
	Label  string
	Locked bool
}

Collection is one collection and whether it is locked.

type Item

type Item struct {
	Path              dbus.ObjectPath
	Label             string
	Attributes        map[string]string
	Created, Modified uint64
	Locked            bool
}

Item is one item as the provider describes it, its secret aside.

type Keychain

type Keychain struct {
	// contains filtered or unexported fields
}

func NewKeychain

func NewKeychain(conn *dbus.Conn) Keychain

func (Keychain) Delete

func (k Keychain) Delete(ctx context.Context, attrs map[string]string) error

func (Keychain) Lookup

func (k Keychain) Lookup(ctx context.Context, attrs map[string]string) (value []byte, found bool, err error)

func (Keychain) Store

func (k Keychain) Store(ctx context.Context, label string, attrs map[string]string, value []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL