Documentation ¶
Overview ¶
client package for 'secret service' as described at: http://standards.freedesktop.org/secret-service
Index ¶
- func Epoch() uint64
- func SliceContains(slice, elem interface{}) (bool, error)
- type CliSession
- type Client
- func (client *Client) AddCollection(collection *Collection)
- func (client *Client) AddSession(session *Session)
- func (client *Client) Call(destination string, dbusPath dbus.ObjectPath, dbusInterface string, ...) (*dbus.Call, error)
- func (client *Client) Connected() bool
- func (client *Client) CreateCollection(properties map[string]dbus.Variant, alias string) (*Collection, dbus.ObjectPath, error)
- func (client *Client) Disconnect() error
- func (client *Client) GetCollectionByPath(collectionPath dbus.ObjectPath) *Collection
- func (client *Client) GetSecrets(items []dbus.ObjectPath, session dbus.ObjectPath) (map[dbus.ObjectPath]SecretApi, error)
- func (client *Client) GetSessionByPath(sessionPath dbus.ObjectPath) *Session
- func (client *Client) HasCollection(collectionPath dbus.ObjectPath) bool
- func (client *Client) HasSession(sessionPath dbus.ObjectPath) bool
- func (client *Client) Lock(objects []dbus.ObjectPath) ([]dbus.ObjectPath, dbus.ObjectPath, error)
- func (client *Client) OpenSession(algorithm EncryptionAlgorithm) (*Session, error)
- func (client *Client) PropertyGetCollections() ([]string, error)
- func (client *Client) ReadAlias(name string) (dbus.ObjectPath, error)
- func (client *Client) RemoveCollection(collection *Collection) error
- func (client *Client) SearchItems(attributes map[string]string) ([]dbus.ObjectPath, []dbus.ObjectPath, error)
- func (client *Client) SecretServiceCommand(command string, params string) (string, error)
- func (client *Client) SetAlias(name string, collection dbus.ObjectPath) error
- func (client *Client) Unlock(objects []dbus.ObjectPath) ([]dbus.ObjectPath, dbus.ObjectPath, error)
- func (client *Client) WatchSignal(signal ServiceSignal, timeout ...time.Duration) (bool, error)
- type Collection
- func (collection *Collection) AddItem(item *Item) error
- func (collection *Collection) CreateItem(properties map[string]dbus.Variant, secretApi *SecretApi, replace bool) (*Item, string, error)
- func (collection *Collection) Delete() (dbus.ObjectPath, error)
- func (collection *Collection) GetItemByPath(itemPath dbus.ObjectPath) *Item
- func (collection *Collection) GetProperty(name string) (dbus.Variant, error)
- func (collection *Collection) Lock()
- func (collection *Collection) PropertyCreated() (uint64, error)
- func (collection *Collection) PropertyGetItems() ([]string, error)
- func (collection *Collection) PropertyGetLabel() (string, error)
- func (collection *Collection) PropertyGetLocked() (bool, error)
- func (collection *Collection) PropertyModified() (uint64, error)
- func (collection *Collection) PropertySetLabel(label string) error
- func (collection *Collection) RemoveItem(itemPath dbus.ObjectPath) error
- func (collection *Collection) SearchItems(attributes map[string]string) ([]dbus.ObjectPath, error)
- func (collection *Collection) SetProperties(properties map[string]dbus.Variant)
- func (collection *Collection) SetProperty(name string, value interface{}) error
- func (collection *Collection) Unlock()
- func (collection *Collection) WatchSignal(signal CollectionSignal, timeout ...time.Duration) (bool, error)
- type CollectionSignal
- type EncryptionAlgorithm
- type Item
- func (item *Item) Delete() (dbus.ObjectPath, error)
- func (item *Item) GetProperty(name string) (dbus.Variant, error)
- func (item *Item) GetSecret(session dbus.ObjectPath) (*SecretApi, error)
- func (item *Item) Lock()
- func (item *Item) PropertyCreated() (uint64, error)
- func (item *Item) PropertyGetAttributes() (map[string]string, error)
- func (item *Item) PropertyGetLabel() (string, error)
- func (item *Item) PropertyGetLocked() (bool, error)
- func (item *Item) PropertyModified() (uint64, error)
- func (item *Item) PropertySetAttributes(attributes map[string]string) error
- func (item *Item) PropertySetLabel(label string) error
- func (item *Item) SetProperty(name string, value interface{}) error
- func (item *Item) SetSecret(secretApi *SecretApi) error
- func (item *Item) Unlock()
- type Prompt
- type PromptSignal
- type Secret
- type SecretApi
- type SecretMap
- type SecretService
- type SecretServiceCLiSession
- type ServiceSignal
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SliceContains ¶
SliceContains returns true if a slice contains an element otherwise false
Types ¶
type CliSession ¶ added in v0.2.0
type CliSession struct { // reference to parent (client) Parent *Client // symmetric key used or AES encryption/decryption. Needs IV as well SymmetricKey []byte // 16 bytes (128 bits) }
func NewCliSession ¶ added in v0.2.0
func NewCliSession(parent *Client) *CliSession
type Client ¶
type Client struct { // dbus session connection Connection *dbus.Conn // dbus object used to call dbus methods DbusObject dbus.BusObject // Signal channel SignalChan chan *dbus.Signal // SecretService session SecretService *SecretService // Mutex for lock/unlock Sessions map SessionsMutex *sync.RWMutex // sessions map. key: session dbus object path, value: session object Sessions map[string]*Session // Cli session // CliSession *CliSession // TODO: REMOVE ME // Mutex for lock/unlock Collections map CollectionsMutex *sync.RWMutex // Collections map. key: Collection dbus object path, value: Collection object Collections map[string]*Collection }
secret service client data structure
func (*Client) AddCollection ¶
func (client *Client) AddCollection(collection *Collection)
AddCollection adds a new collection to client's collection map
func (*Client) AddSession ¶
AddSession adds a new session to client's session map
func (*Client) Call ¶
func (client *Client) Call(destination string, dbusPath dbus.ObjectPath, dbusInterface string, methodName string, args ...interface{}) (*dbus.Call, error)
Call performs low-level method Call on org.freedesktop.secrets objects Don't use this method directly unless you know what you are doing!
func (*Client) Connected ¶
Connected returns true if client is connected to session dbus otherwise false
func (*Client) CreateCollection ¶
func (client *Client) CreateCollection(properties map[string]dbus.Variant, alias string) (*Collection, dbus.ObjectPath, error)
CreateCollection creates a collection for storing items item = secret + lookup attributes + label
func (*Client) Disconnect ¶
Disconnect from session dbus CAUTION: connection is shared by all clients by closing it all clients fail on subsequent operations
func (*Client) GetCollectionByPath ¶
func (client *Client) GetCollectionByPath(collectionPath dbus.ObjectPath) *Collection
GetCollectionByPath returns a collection based on its path, otherwise null
func (*Client) GetSecrets ¶
func (client *Client) GetSecrets(items []dbus.ObjectPath, session dbus.ObjectPath) (map[dbus.ObjectPath]SecretApi, error)
GetSecrets returns secrets associated to given object paths
func (*Client) GetSessionByPath ¶
GetSessionByPath returns a session based on its path otherwise null
func (*Client) HasCollection ¶
HasCollection returns true if collection exists otherwise false
func (*Client) HasSession ¶
HasSession returns true if session exists otherwise false
func (*Client) Lock ¶
Lock, locks given objects based on their paths and returns an array of locked object paths
func (*Client) OpenSession ¶
func (client *Client) OpenSession(algorithm EncryptionAlgorithm) (*Session, error)
OpenSession creates a session for encrypted or non-encrypted further communication
func (*Client) PropertyGetCollections ¶
PropertyGetCollections returns Collections property of Service
func (*Client) RemoveCollection ¶
func (client *Client) RemoveCollection(collection *Collection) error
RemoveCollection removes a collection from client's Collections map
func (*Client) SearchItems ¶
func (client *Client) SearchItems( attributes map[string]string) ([]dbus.ObjectPath, []dbus.ObjectPath, error)
SearchItems searches for items in this collection matching the lookup attributes
func (*Client) SecretServiceCommand ¶ added in v0.2.0
OpenSession creates a session for encrypted or non-encrypted further communication
func (*Client) Unlock ¶
func (client *Client) Unlock( objects []dbus.ObjectPath) ([]dbus.ObjectPath, dbus.ObjectPath, error)
Unlock, unlocks given objects based on their paths and returns an array of unlocked object paths
func (*Client) WatchSignal ¶
WatchSignal watches for desired signal within a time period If signal is received it returns true, otherwise false
type Collection ¶
type Collection struct { // reference to parent (client) Parent *Client // Signal channel SignalChan chan *dbus.Signal // Mutex for lock/unlock Items slice ItemsMutex *sync.RWMutex // Items map. key: Item dbus object path, value: Item object Items map[string]*Item // collection full dbus object path ObjectPath dbus.ObjectPath // Mutex for lock/unlock Properties map PropertiesMutex *sync.RWMutex // collection Properties map Properties map[string]dbus.Variant // collection alias (friendly name) Alias string // Mutex to lock/unlock Locked status of collection LockMutex *sync.Mutex // collection Label Label string // true if collection is locked otherwise false Locked bool // Unix time collection created Created uint64 // Unix time collection modified Modified uint64 // contains filtered or unexported fields }
Collection data structure collection consists of items
func NewCollection ¶
func NewCollection(parent *Client) (*Collection, error)
NewCollection creates and initialize a new collection and returns it
func (*Collection) AddItem ¶
func (collection *Collection) AddItem(item *Item) error
AddItem adds given item to the collection
func (*Collection) CreateItem ¶
func (collection *Collection) CreateItem(properties map[string]dbus.Variant, secretApi *SecretApi, replace bool) (*Item, string, error)
CreateItem creates an Item in a collection item = secret + lookup attributes + label
func (*Collection) Delete ¶
func (collection *Collection) Delete() (dbus.ObjectPath, error)
Delete removes the collection
func (*Collection) GetItemByPath ¶
func (collection *Collection) GetItemByPath(itemPath dbus.ObjectPath) *Item
GetItemByPath returns an item based on its path, otherwise null
func (*Collection) GetProperty ¶
func (collection *Collection) GetProperty(name string) (dbus.Variant, error)
GetProperty returns given dbus property value
func (*Collection) PropertyCreated ¶
func (collection *Collection) PropertyCreated() (uint64, error)
PropertyCreated returns 'Created' property of the collection
func (*Collection) PropertyGetItems ¶
func (collection *Collection) PropertyGetItems() ([]string, error)
PropertyGetItems returns 'Items' property of the collection
func (*Collection) PropertyGetLabel ¶
func (collection *Collection) PropertyGetLabel() (string, error)
PropertyGetLabel returns 'Label' property of the collection
func (*Collection) PropertyGetLocked ¶
func (collection *Collection) PropertyGetLocked() (bool, error)
PropertyGetLocked returns 'Locked' property of the collection
func (*Collection) PropertyModified ¶
func (collection *Collection) PropertyModified() (uint64, error)
PropertyModified returns 'Modified' property of the collection
func (*Collection) PropertySetLabel ¶
func (collection *Collection) PropertySetLabel(label string) error
PropertySetLabel changes 'Label' property of the collection to the given value
func (*Collection) RemoveItem ¶
func (collection *Collection) RemoveItem(itemPath dbus.ObjectPath) error
RemoveItem removes an item from the collection
func (*Collection) SearchItems ¶
func (collection *Collection) SearchItems(attributes map[string]string) ([]dbus.ObjectPath, error)
SearchItems Searches for items in this collection matching the lookup attributes
func (*Collection) SetProperties ¶
func (collection *Collection) SetProperties(properties map[string]dbus.Variant)
SetProperties processes raw properties and sets collection.Properties
func (*Collection) SetProperty ¶
func (collection *Collection) SetProperty(name string, value interface{}) error
SetProperty sets given dbus property name to given value
func (*Collection) WatchSignal ¶
func (collection *Collection) WatchSignal(signal CollectionSignal, timeout ...time.Duration) (bool, error)
WatchSignal watches for desired signal within a time period If signal is received it returns true, otherwise false
type CollectionSignal ¶
type CollectionSignal uint8
org.freedesktop.Secret.Collection signals
const ( ItemCreated CollectionSignal = iota ItemDeleted ItemChanged )
type EncryptionAlgorithm ¶
type EncryptionAlgorithm uint8
encryption algorithm type plain or Dh_ietf1024_sha256_aes128_cbc_pkcs7
const ( // Plain algorithm (no encryption) Plain EncryptionAlgorithm = iota // Dh_ietf1024_sha256_aes128_cbc_pkcs7 algorithm Dh_ietf1024_sha256_aes128_cbc_pkcs7 // Unsupported algorithm (used in tests) Unsupported )
type Item ¶
type Item struct { // reference to parent (collection) Parent *Collection // item full dbus object path ObjectPath dbus.ObjectPath // secret contained in this item Secret *Secret // Mutex for lock/unlock LookupAttributes slice LookupAttributesMutex *sync.RWMutex // LookupAttributes (name + value) contained in this item LookupAttributes map[string]string // label of this item Label string // Mutex to lock/unlock Locked status of item LockMutex *sync.Mutex // true if item is locked otherwise false Locked bool // Unix time item created Created uint64 // Unix time item modified Modified uint64 }
Item data structure item = secret + lookup attributes + label
func NewItem ¶
func NewItem(parent *Collection) *Item
NewCollection creates and initialize a new collection and returns it
func (*Item) GetProperty ¶
GetProperty returns given dbus property value
func (*Item) PropertyCreated ¶
PropertyCreated returns 'Created' property of the item
func (*Item) PropertyGetAttributes ¶
PropertyGeAttributes returns 'Attributes' property of the item
func (*Item) PropertyGetLabel ¶
PropertyGetLabel returns 'Label' property of the item
func (*Item) PropertyGetLocked ¶
PropertyGetLocked returns 'Locked' property of the item
func (*Item) PropertyModified ¶
PropertyModified returns 'Modified' property of the item
func (*Item) PropertySetAttributes ¶
PropertySetAttributes changes 'Attributes' property of the item to the given value
func (*Item) PropertySetLabel ¶
PropertySetLabel changes 'Label' property of the item to the given value
func (*Item) SetProperty ¶
SetProperty sets given dbus property name to given value
type Prompt ¶
type Prompt struct { // reference to parent (client) Parent *Client // Signal channel SignalChan chan *dbus.Signal // prompt full dbus object path ObjectPath dbus.ObjectPath // client applications can use the window-id to // display the prompt attached to their application window WindowId string }
Prompt data structure
func (*Prompt) Prompt ¶
Prompt performs the prompt. A prompt necessary to complete an operation windowId: Platform specific window handle to use for showing the prompt
func (*Prompt) WatchSignal ¶
WatchSignal watches for desired signal within a time period If signal is received it returns true, otherwise false
type PromptSignal ¶
type PromptSignal uint8
org.freedesktop.Secret.Prompt signal
const (
Completed PromptSignal = iota
)
type Secret ¶
type Secret struct { // reference to parent (item) Parent *Item // Unencrypted secret PlainSecret string // Secret type needed bu API SecretApi *SecretApi }
Secret data structure
type SecretApi ¶
type SecretApi struct { // The session full dbus object path that was used to encode the secret Session dbus.ObjectPath // Algorithm dependent parameters for secret value encoding Parameters []byte // Possibly encoded secret value Value []byte //The content type of the secret i.e. ‘text/plain; charset=utf8’ ContentType string }
Secret data structure needed bu API
func NewSecretApi ¶
func NewSecretApi() *SecretApi
NewSecret returns a new instance of SecretApi SecretApi is the exact secret structure accordinf to API Secret is a wrapper around SecretApi to hold extra information
type SecretMap ¶
type SecretMap map[dbus.ObjectPath]Secret
A mapping from object-paths to Secret structs
type SecretService ¶ added in v0.2.0
type SecretService struct { // reference to parent (service) Parent *Client // session (public key negotiation) Session *SecretServiceCLiSession }
CLI interface data structure
type SecretServiceCLiSession ¶ added in v0.2.0
type SecretServiceCLiSession struct { // symmetric key used or AES encryption/decryption. Needs IV as well SymmetricKey []byte // 16 bytes (128 bits) }
session (public key negotiation)
type ServiceSignal ¶
type ServiceSignal uint8
org.freedesktop.Secret.Service signals
const ( CollectionCreated ServiceSignal = iota CollectionDeleted CollectionChanged )
type Session ¶
type Session struct { // reference to parent (client) Parent *Client // session full dbus object path ObjectPath dbus.ObjectPath // encryption algorithm type EncryptionAlgorithm EncryptionAlgorithm // symmetric key used or AES encryption/decryption. Needs IV as well SymmetricKey []byte // 16 bytes (128 bits) // client public key used or AES encryption/decryption ServicePublicKey []byte // 128 bytes (1024 bits) }
Session data structure
func NewSession ¶
NewSession creates and initialize a new session
Source Files ¶
- client.go
- collection.go
- collection_create-item.go
- collection_delete.go
- collection_search-items.go
- entities.go
- item.go
- item_delete.go
- item_get-secret.go
- item_set-secret.go
- prompt.go
- prompt_dismiss.go
- prompt_prompt.go
- secret.go
- secretservice_command.go
- service_create-collection.go
- service_get-secrets.go
- service_lock.go
- service_open-session.go
- service_read-alias.go
- service_search-items.go
- service_set-alias.go
- service_unlock.go
- session.go
- session_close.go
- utils.go