Documentation ¶
Overview ¶
Package passwords contains the in memory data manipulations for password repo.
Index ¶
- Constants
- Variables
- func InitRepo(mPassword string) error
- type CSVExporter
- type CSVImporter
- type DB
- type Entry
- type Exporter
- type ExporterFactory
- type ImportExportEntry
- type Importer
- type ImporterFactory
- type Repository
- func (p *Repository) Add(id, uN, password, desc string, labels []string) error
- func (p *Repository) ChangeMasterPassword(newPassword string) error
- func (p *Repository) ChangePasswordEntry(id string, entry Entry) error
- func (p *Repository) Export(exporterID string, conf map[string]string) error
- func (p *Repository) GetPasswordEntry(id string) (Entry, error)
- func (p *Repository) GetUsernamePassword(id string, showPassword bool) error
- func (p *Repository) Import(importerID string, conf map[string]string) error
- func (p *Repository) Remove(id string) error
- func (p *Repository) SearchEntriesByID(id string) ([]Entry, error)
- func (p *Repository) SearchLabel(label string) ([]Entry, error)
- func (p *Repository) UpgradeDB() error
Constants ¶
const ( //CSVExporterID is the CSV exporter ID. CSVExporterID = "CSV_EXPORTER" //CSVImporterID is the CSV importer ID. CSVImporterID = "CSV_IMPORTER" // CSVSeparator represents the separator for CSV file. CSVSeparator = "," //ConfKeyCSVFilePath represents the CSV path key in the conf map. ConfKeyCSVFilePath = "CONF_KEY_CSV_PATH" )
Variables ¶
var ( // DatabaseVersion represents the database version. DatabaseVersion string // ErrInvalidID represents the invalid ID error. ErrInvalidID = func(id string) error { return errors.New(fmt.Sprintf("Invalid ID: %s", id)) } // ErrCannotSavePasswordDB represents the error when it is unable to save password entry. ErrCannotSavePasswordDB = func(err error) error { return errors.Wrap(err, "cannot save password db") } // ErrNoPasswords represents the error when no passwords are available. ErrNoPasswords = errors.New("no passwords are available") // ErrCannotFindMatchForID represents the error when it is unable to find a password entry for the given ID. ErrCannotFindMatchForID = func(id string) error { return errors.New(fmt.Sprintf("cannot find any match for id %s", id)) } )
Functions ¶
Types ¶
type CSVExporter ¶ added in v0.8.0
type CSVExporter struct {
// contains filtered or unexported fields
}
CSVExporter struct is used to export password entries.
func (*CSVExporter) Export ¶ added in v0.8.0
func (e *CSVExporter) Export(entries []ImportExportEntry) error
Export exports password entries to a CSV file.
func (*CSVExporter) Init ¶ added in v0.8.0
func (e *CSVExporter) Init(conf map[string]string)
Init initialize the CSV Exporter.
type CSVImporter ¶ added in v0.8.0
type CSVImporter struct {
// contains filtered or unexported fields
}
CSVImporter struct is used to import password entries.
func (*CSVImporter) Import ¶ added in v0.8.0
func (i *CSVImporter) Import() ([]ImportExportEntry, error)
Import imports password entries from a CSV file.
func (*CSVImporter) Init ¶ added in v0.8.0
func (i *CSVImporter) Init(conf map[string]string)
Init initialize the CSV Importer.
type DB ¶ added in v0.7.0
type DB struct { Version string `json:"version"` Entries map[string]Entry `json:"entries"` Labels map[string][]string `json:"labels"` }
DB struct represents password db.
type Entry ¶ added in v0.7.0
type Entry struct { ID string `json:"id"` Username string `json:"username"` Password string `json:"password"` Description string `json:"description,omitempty"` }
Entry struct represents entry in the password db.
type Exporter ¶ added in v0.8.0
type Exporter interface { // Init initialises the exporter. Init(conf map[string]string) // Export exports the importExport entries. Export(entries []ImportExportEntry) error }
Exporter interface is used to export data.
type ExporterFactory ¶ added in v0.8.0
type ExporterFactory struct {
ID string
}
ExporterFactory used to create an Exporter.
func (*ExporterFactory) Exporter ¶ added in v0.8.0
func (e *ExporterFactory) Exporter() Exporter
Exporter returns the requested an Exporter.
type ImportExportEntry ¶ added in v0.8.0
ImportExportEntry struct represents an import/export entry.
type Importer ¶ added in v0.8.0
type Importer interface { // Init initialises the importer. Init(conf map[string]string) // Import imports the importExport entries. Import() ([]ImportExportEntry, error) }
Importer interface is used to import data.
type ImporterFactory ¶ added in v0.8.0
type ImporterFactory struct {
ID string
}
ImporterFactory used to create an Importer.
func (*ImporterFactory) Importer ¶ added in v0.8.0
func (e *ImporterFactory) Importer() Importer
Importer returns the requested an Importer.
type Repository ¶ added in v0.7.0
type Repository struct {
// contains filtered or unexported fields
}
Repository struct handles Password db.
func LoadRepo ¶ added in v0.7.0
func LoadRepo(mPassword string, withoutVersionCheck bool) (*Repository, error)
LoadRepo initializes the Password repository. This function initialises each component of the password repository.
func (*Repository) Add ¶ added in v0.7.0
func (p *Repository) Add(id, uN, password, desc string, labels []string) error
Add method add new password entry to Password db.
func (*Repository) ChangeMasterPassword ¶ added in v0.7.0
func (p *Repository) ChangeMasterPassword(newPassword string) error
ChangeMasterPassword changes the master password.
func (*Repository) ChangePasswordEntry ¶ added in v0.7.0
func (p *Repository) ChangePasswordEntry(id string, entry Entry) error
ChangePasswordEntry changes the password entry.
func (*Repository) Export ¶ added in v0.8.0
func (p *Repository) Export(exporterID string, conf map[string]string) error
Export exports the password database.
func (*Repository) GetPasswordEntry ¶ added in v0.7.0
func (p *Repository) GetPasswordEntry(id string) (Entry, error)
GetPasswordEntry gets the password entry from password db.
func (*Repository) GetUsernamePassword ¶ added in v0.7.0
func (p *Repository) GetUsernamePassword(id string, showPassword bool) error
GetUsernamePassword method retrieves username and password from Password db.
func (*Repository) Import ¶ added in v0.8.0
func (p *Repository) Import(importerID string, conf map[string]string) error
Import imports the password database.
func (*Repository) Remove ¶ added in v0.7.0
func (p *Repository) Remove(id string) error
Remove removes the password entry of the given id.
func (*Repository) SearchEntriesByID ¶ added in v0.9.1
func (p *Repository) SearchEntriesByID(id string) ([]Entry, error)
SearchEntriesByID will return the password entries if the password ID contains the provide key.
func (*Repository) SearchLabel ¶ added in v0.7.0
func (p *Repository) SearchLabel(label string) ([]Entry, error)
SearchLabel will return the password entries if the password labels contains the provide label.
func (*Repository) UpgradeDB ¶ added in v0.9.1
func (p *Repository) UpgradeDB() error
UpgradeDB method upgrades the password database to the latest version.