Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce age plugin for managing encryption and decryption keys. #509

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

jmsnll
Copy link

@jmsnll jmsnll commented Jan 15, 2025

Overview

Adds a new plugin for the age command-line tool to securely handle encryption and decryption credentials with 1Password CLI. Currently supports asymmetric encryption with the same public/private key pair. Users can manually specify multiple recipients as they usually would.

There is no standard location or placement of age identity files so I have not written an importer.

Type of change

  • Created a new plugin
  • Improved an existing plugin
  • Fixed a bug in an existing plugin
  • Improved contributor utilities or experience

Related Issue(s)

How To Test

1. Generate a key pair

Use age-keygen to create a public and private key pair. Store these keys in a new credential in 1Password:

  • Add a field named private_key to store the private key
  • Add a field named public_key to store the public key

Example output from age-keygen

$ age-keygen | tee age.txt
# created: 2025-01-16T00:00:00+01:00
# public key: age109acfr42tp05673rnpzngnuc48p08pma83r5a78kunn63m3hh45EXAMPLE
AGE-SECRET-KEY-1CR6CWDH03049DHY0ZPG9QNNRT39AHP96Q633LQQGEUPS9A0PYVGEXAMPLE

2. Initialise the plugin

Run the following command and select the credential you created:

op plugin init age

The 1Password CLI will now automatically populate the -i/--identity and -R/--recipients flags for encryption and decryption.

3. Using Age with the plugin

Use the age plugin to encrypt a file:

age -o encrypted.txt plaintext.txt

Decrypt the encrypted file:

age -d -o unencrypted.txt encrypted.txt

4. Using Age without plugin

Use the age plugin to encrypt a file:

age -r age109acfr42tp05673rnpzngnuc48p08pma83r5a78kunn63m3hh45EXAMPLE -o encrypted.txt plaintext.txt

Decrypt the encrypted file:

age -d -i age.txt -o unencrypted.txt encrypted.txt

Changelog

Add age plugin for secure key management, auto-populating stored identity and recipients for encryption and decryption.

jmsnll and others added 14 commits January 16, 2025 00:16
- some commands (like `age`) have positional argument which require to be placed after all flag arguments
- change allows prepending of args to after the command itself instead of just appending to the end and potentially causing issues

Signed-off-by: James Neill <[email protected]>
- include handling of user adding conflicting identity flag

Signed-off-by: James Neill <[email protected]>
…li flags

- if no explicit flags are detected the default to encryption mode as `age` does

Signed-off-by: James Neill <[email protected]>
- supports providing different handlers for different operation types (i.e. decrypt, encrypt)
- in the future operation types could be extended depending potentially on argument combinations to allow better handling of edge case scenarios

Signed-off-by: James Neill <[email protected]>
- accidenally changed at some point during development
- as a result no longer need operation mode handlers
- errors can be moved entirely into the provisioner module
@NeckBeardPrince
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New plugin: Age
2 participants