Documentation
¶
Index ¶
Constants ¶
const ( SecretServiceDest = "org.freedesktop.secrets" SecretServicePrefix = "org.freedesktop.Secret." SecretServicePath = "/org/freedesktop/secrets" CollectionInterface = SecretServicePrefix + "Collection" SessionInterface = SecretServicePrefix + "Session" ItemInterface = SecretServicePrefix + "Item" ServiceInterface = SecretServicePrefix + "Service" PromptInterface = SecretServicePrefix + "Prompt" DefaultCollection = SecretServicePath + "/aliases/default" SessionCollection = SecretServicePath + "/collection/session" AlgPlain = "plain" // AlgDH is not yet supported only AlgPlain is supported AlgDH = "dh-ietf1024-sha256-aes128-cbc-pkcs7" )
Variables ¶
This section is empty.
Functions ¶
func ErrInvalidType ¶
Types ¶
type Collection ¶
type Collection interface {
// Path returns the ObjectPath of the collection
Path() dbus.ObjectPath
// GetLabel returns the label of the collection
GetLabel() (string, error)
// SetLabel sets the label of the connection
SetLabel(l string) error
// Locked returns true if the collection is locked
Locked() (bool, error)
// Delete deletes the collection and handles any prompt required
Delete() error
// GetAllItems returns all items in the collection
GetAllItems() ([]Item, error)
// GetItem returns the first item with the given label
GetItem(name string) (Item, error)
// SearchItems searches for items in the collection
SearchItems(attrs map[string]string) ([]Item, error)
// CreateItem creates a new item inside the collection optionally overwritting an
// existing one
CreateItem(session dbus.ObjectPath, label string, attr map[string]string, secret []byte, contentType string, replace bool) (Item, error)
}
Collection provides access secret collections from org.freedesktop.secret The DBus specification for org.freedesktop.Secret.Collection can be found at https://specifications.freedesktop.org/secret-service/re02.html
func GetCollection ¶
func GetCollection(conn *dbus.Conn, path dbus.ObjectPath) (Collection, error)
GetCollection returns a collection object for the specified path
type Item ¶
type Item interface {
// Locked returns true if the item is currently locked
Locked() (bool, error)
// Unlock unlocks the item and handles any prompt that might be required
Unlock() (bool, error)
// GetAttributes returns the items attributes
GetAttributes() (map[string]string, error)
// SetAttributes sets the items attributes
SetAttributes(map[string]string) error
// GetLabel returns the label of the item
GetLabel() (string, error)
// SetLabel sets the item's label
SetLabel(string) error
// Delete deletes the item any handles any prompt that might be required
Delete() error
// GetSecret returns the secret of the item
GetSecret(session dbus.ObjectPath) (*Secret, error)
// SetSecret sets the secret of the item
SetSecret(dbus.ObjectPath, []byte, string) error
// GetCreated returns the time the item has been created
GetCreated() (time.Time, error)
// GetModified returns the time the item has been last modified
GetModified() (time.Time, error)
}
Item implements a wrapper for org.freedesktop.Secret.Item as defined here https://specifications.freedesktop.org/secret-service/re03.html
type Prompt ¶
type Prompt interface {
// Path returns the ObjectPath of the prompt
Path() dbus.ObjectPath
// Prompt performs the prompt
Prompt(windowID string) (<-chan *dbus.Variant, error)
// Dismiss dismisses the prompt. It is no longer valid after calling Dismiss()
Dismiss() error
}
Prompt provides interaction with the Prompt interface from Freedesktop.org's Secret Service API it's defined at https://specifications.freedesktop.org/secret-service/re05.html
type SecretService ¶
type SecretService interface {
// OpenSession opens a unique session for the calling application
OpenSession() (Session, error)
// GetCollection returns the collection with the given name
GetCollection(name string) (Collection, error)
// GetAllCollections returns all collections stored in the secret service
GetAllCollections() ([]Collection, error)
// GetDefaultCollection returns the default collection of the secret service
// ( DBus path = /org/freedesktop/secrets/aliases/default )
GetDefaultCollection() (Collection, error)
// SearchItems finds all items in any collection and returns them either
// in the unlocked or locked slice
SearchItems(map[string]string) (unlocked []Item, locked []Item, err error)
// GetSecrets returns multiple secrets from different items
GetSecrets(paths []dbus.ObjectPath, session dbus.ObjectPath) (map[dbus.ObjectPath]*Secret, error)
// ReadAlias resolves the alias (like 'default') to the object path of the
// referenced collection
ReadAlias(name string) (dbus.ObjectPath, error)
// SetAlias creates a new alias for the given collection path
// Note that if path is "/", the alias will be deleted
// see https://specifications.freedesktop.org/secret-service/re01.html#org.freedesktop.Secret.Service.SetAlias
SetAlias(name string, path dbus.ObjectPath) error
// RemoveAlias removes the provided alias. This is a utility method for SetAlias(name, "/")
RemoveAlias(name string) error
// CreateCollection creates a new collection with the given properties and an optional alias (leave empty for no alias)
// It also handles any prompt that may be required
CreateCollection(label string, alias string) (Collection, error)
// Lock locks items or collections and handles any prompt that may be required
Lock(paths []dbus.ObjectPath) ([]dbus.ObjectPath, error)
// Unlock unlocks items or collections and handles any prompt that may be required
Unlock(paths []dbus.ObjectPath) ([]dbus.ObjectPath, error)
}
SecretService manages all the sessions and collections it's defined in org.freedesktop.Secret.Service https://specifications.freedesktop.org/secret-service/re01.html
func GetSecretService ¶
func GetSecretService(conn *dbus.Conn) (SecretService, error)
GetSecretService returns a client to the SecretService (org.freedesktop.secrets) on the provided DBus connection
type Session ¶
type Session interface {
// Path returns the object path of the session
// To get a new session use SecretService.OpenSession()
Path() dbus.ObjectPath
// Close closes the session
Close() error
}
Session allows to interact with the Session interface of Freedesktop.org's Secret Service API The session interface is defined at https://specifications.freedesktop.org/secret-service/re01.html
func GetSession ¶
GetSession returns a new Session for the provided path. Note that session must be opened beforehand Use SecretService.OpenSession() to open a new session and return a Session client