Package: harpo
DescriptionHarpocrates (Ancient Greek: Ἁρποκράτης) was the god of silence, secrets and confidentiality.Harpois GPG-based secret storage/sharing library.It is aims to be a convenient wrapper around GPG and tries to solve the following problems:Storing secrets in a repository in a secure mannerProviding a group-based access to the stored secretsProviding an easy way to re-encrypt secretsIt was inspired byblackboxby StackExchange.Quick StartInitializeInitialize harpo in a current directory:harposysteminitThis will create.harpodirectory that will contain your secrets and all required metadata.Create DomainDomain — is a ‘directory’ for secrets. To be honest, itisa directory that contains GPG-encrypted files, plus some metadata.Let’s create one and name itsecrets:harpodomaincreatesecretsCreate UserUser is a Harpo’s word for ‘recipient’. A User must have a GPG key attached to it so that Harpo will use it then
to encrypt secrets.The process of adding a user consists of two steps: add a key, create a user associated with this key:1. add a keyThis guide assumes that you already have your GPG key in your default keyring.
Let’s export your GPG public key and add it to Harpo:gpg--export--armoryour-key-fingerprint|harpokeycreate-2. create a userThe following command will create a user namedaliceassociated with your GPG public key:harpousercreatealiceyour-key-fingerprintLet’s verify by runningharpo user list. The output should look like:+--------+------------------------------------------+
| name   | key_fingerprint                          |
|--------+------------------------------------------|
| alice  | A8EE4ED8DDFC3EFFD26EC0042477DBC294CF0AF0 |
+--------+------------------------------------------+Create Group (optional)While you can skip this step if you have just one or two users, it’s just a lot more convenient to organize your users into groups if you have many of them.Let’s create a group and add Alice to it:harpogroupcreateadminsharpogroupmembersaddadminsaliceYou can verify withharpo group listthat will return you a flat list:adminsdevelopersusersYou can also list a groups table with members usingharpo group list --members:+--------+-----------+
| name   | members   |
|--------+-----------|
| admins | ['alice'] |
+--------+-----------+Grant access to DomainNow we have to tell Harpo that our user/group should be able to manage secrets in Domainsecrets:harpodomainallowsecrets%adminsNote the%character! Just like in sudoers, this character tells the program to treatadminsas a group.ORIf you want to grant access just to auser, not a group:harpodomainallowsecretsaliceYou can verify this withharpo domain info secrets:+---------+----------+-------------+--------+----------------------+-----------+--------------+
| name    | parent   | allow       | deny   | inherit_recipients   | comment   | recipients   |
|---------+----------+-------------+--------+----------------------+-----------+--------------|
| secrets | None     | ['%admins'] | []     | True                 | None      | ['alice']    |
+---------+----------+-------------+--------+----------------------+-----------+--------------+In columnallowyou can see users and groups that have access to this domain.In column recipients you can see a final set of recipients for this domain.
These users will be the recipients of a GPG-encrypted secret that Harpo will create.Create a secretFinally we can encrypt something.You have two slightly different ways of creating a secret using Harpo CLI. Let’s go through them:1. pass secret value as an argumentharpo secret create [OPTIONS] DOMAIN_NAME SECRET_NAME SECRET_VALUEharposecretcreatesecretsfoobar2. interactive editor (beta)You also have an option to launch your favorite editor!harposecreteditsecretsfooVIM users: There is a known issue with vim when backup files are enabled - Harpo won’t save your edits at all.
You can disable backup files withnobackupdirective.Read a secretThis is pretty straightforward:harposecretreadsecretsfooDocumentationDomainDomain — is a logical group of secrets. You can think of domain as a directory that contains secrets and other domains.PropertiesDomains have following properties:name— the name of a Domainchildren— each Domain can have any number of subdomains, i.e. children.
By default all permissions are inherited from the parent to children.
This property is not stored in metadata but instead populated in runtime.parent— Every Domain has a parent except the root (top level) Domains. Root Domains has no parents.allow— list of Groups and Users that have access to this Domain.deny— list of Groups and Users that are explicitly denied to become a recipients for secrets in this Domain.recipients— a set of Users that are derived from the list of(allow - deny)that have access to this Domain.
This property is not stored in metadata but instead populated in runtime.inherit_recipients— controls how a given Domain should inherit recipients from its parent.
Currently only two modes are available: True and False. Inheritance can be disabled during Domain creation from CLI
by adding--no-inherit-recipientsflag.Storage & metadataDomains are mapped to filesystem as directories and can be found in.harpo/data.Every Domain also has an associated metadata in.harpo/meta/domain.json.KeyKey is one of the simplest entities in Harpo. It’s just that: a GPG public key that is stored in the Harpo’s keyring.Propertiesfingerprint— GPG key fingerprint; the main property of a KeyStorage & metadataHarpo’s keyring can be found in.harpo/keystore/pubring.gpg.Keys don’t use any metadata.UserIn Harpo prior 1.0 users were represented by GPG keys only. Harpo 1.0 adds a new separate entity for users.This being said, Users are still mapped to Keys as 1-to-1, but this probably will change in the future
(allowing a single User to have multiple GPG keys, for example).Currently User is just a named mapping to a Key.Propertiesname— the name of a Userkey_fingerprint— a GPG key fingerprint of a key that is associated with this User.Storage & metadataUsers metadata can be found in.harpo/meta/user.jsonGroupGroup — is a set of Users. Currently groups can’t contain other groups.Propertiesname— the name of a Groupmembers— list of membersStorage & metadataGroups metadata can be found in.harpo/meta/group.jsonSecretSecret — is a GPG-encrypted data inside Domain.To encrypt a secret Harpo needs to know the list of recipients.
Harpo gets this information form Domain that holds this secret.With one notable exception…Shared Secretsare secrets with the name that ends with.shared.These secrets are special in a way that they are encrypted with not only with keys
belonging to recipients of a Domain that holds these secrets, but also with keys of recipients from this Domain’s subdomains.This requires an example.An exampleLet’s say we have the following Domain hierarchy:secrets    (allow: alice)
├── bar
│   ├── quux    (bob)  --no-inherit-recipients
│   │   └── credit-cards
│   └── secret.shared
└── baz    (jane)
    └── passwordssecrets — root Domainbar — a child Domain ofbar; it has a Secret calledsecret.sharedquux — a child Domain ofquux; it has a Secret calledcredit-cards;
it was created with--no-inherit-recipientsbaz — another child Domain ofsecrets; it has a Secret calledpasswordsallowed users are specified inside parenthesisQ: So, who can decryptsecret.shared?A: Alice and Bob can decrypt it because it’s a shared Secret.
Harpo will use the following keys to encrypt it:Alice — because she has access to the root domain andbarinherits recipients from its parentBob — because shared secrets are encrypted with keys from subdomainsJane does NOT have access to the shared secrets.Q: OK, how aboutpasswords?A: Alice and Jane. Bob has no access to this secret because it’s not shared
and he only has access to his own subdomainquuxQ: Andcredit-cards?A: Only Bob has access to this secret. Even though Alice has access to the root domainsecrets,
Harpo won’t use her key to encrpyptcredit-cardsbecausequuxdoesn’t inherit recipients.PropertiesSecrets don’t demonstrate any interesting properties, really.name— name of a SecretStorage & MetadataSecrets are stored as GPG encrypted files in.harpo/data/<domain_name>/<secret_name>.AutocompletionFor Bash, add this to ~/.bashrc:eval "$(_HARPO_COMPLETE=bash_source harpo)"For Zsh, add this to ~/.zshrc:eval "$(_HARPO_COMPLETE=zsh_source harpo)"For Fish, add this to ~/.config/fish/completions/harpo.fish:eval (env _HARPO_COMPLETE=fish_source harpo)Open a new shell to enable completion. Or run the eval command directly in your current shell to enable it temporarily.