Categorygithub.com/ppacher/go-dbus-keyring
modulepackage
1.0.1
Repository: https://github.com/ppacher/go-dbus-keyring.git
Documentation: pkg.go.dev

# README

go-dbus-keyring

A GoLang module for querying a keyring application implementing the SecretService DBus specification defined here.

It is based on the awesome dbus library godbus/dbus (which is the only dependecy of the project).

Features

  • Full SecretService implementation
  • Manage collections
  • Manage items/secrets
  • Automatically handles user prompts

Missing Features

  • A server package to implement you own keyring manager
  • Support for encrypted secrets (currently only PLAIN is supported)
  • Support for signals emitted by various SecretService interfaces (only prompts are supported)
  • Unit tests :(

Usage

go-dbus-keyring is setup as a go1.12 module and can be added to any project like this:

go get -u github.com/ppacher/go-dbus-keyring@v1

This project follows Semantic Versioning as required by go-modules. Those, there will be now API changes in major releases!

The documentation for this project is available on godoc.org. In addition, there's a simple example inside the _examples directory.

package main

import (
    "github.com/godbus/dbus/v5"
    keyring "github.com/ppacher/go-dbus-keyring"
)

func main() {
    bus := dbus.SessionBus()
    
    // Get a SecretService client
    secrets, _ := keyring.GetSecretService(bus)

    // Search for the collection with name "my-collection".
    // You can also use secrets.GetDefaultCollection() or secrets.GetAllCollections()
    collection, _ := secrets.GetCollection("my-collection")
    
    // Search for the item with name "my-password"
    item, _ := collection.GetItem("my-password")
    
    // make sure it is unlocked
    // this also handles any prompt that may be required
    _ = item.Unlock()

    secret, _ := item.GetSecret()
    fmt.Println(string(secret.Value))
}

Contributions

Contributions to this project are welcome! Just fork the repository and create a pull request! If you need help to get started checkout the github documentation on creating pull requests.

License

go-dbus-keyring is available under a Simplified BSD License. See LICENSE file for the full text.

# Functions

No description provided by the author
GetCollection returns a collection object for the specified path.
GetItem returns a new item client for the specified path.
GetPrompt returns a Prompt client for the given path.
GetSecretService returns a client to the SecretService (org.freedesktop.secrets) on the provided DBus connection.
GetSession returns a new Session for the provided path.

# Constants

AlgDH is not yet supported only AlgPlain is supported.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Secret defines the DBUS STRUCT for a secret.

# Interfaces

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.
Item implements a wrapper for org.freedesktop.Secret.Item as defined here https://specifications.freedesktop.org/secret-service/re03.html.
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.
SecretService manages all the sessions and collections it's defined in org.freedesktop.Secret.Service https://specifications.freedesktop.org/secret-service/re01.html.
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.