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

Integration with age plugins #68

Merged
merged 9 commits into from
Dec 27, 2021
Merged

Conversation

vtuan10
Copy link
Contributor

@vtuan10 vtuan10 commented Dec 25, 2021

This adds support for age plugins, such as the YubiKey.

PR to add age-plugin-yubikey to nixpkgs: NixOS/nixpkgs#152042

With the release of [rage v0.6.0](https://github.com/str4d/rage/releases/tag/v0.6.0) a plugin system was introduced.
Using this plugin system rage supports identities and recipients from third-parties such as the [YubiKey](https://github.com/str4d/age-plugin-yubikey).
@vtuan10 vtuan10 marked this pull request as draft December 25, 2021 14:09
@vtuan10 vtuan10 force-pushed the age-plugin-yubikey-integration branch from 60ee732 to fb7870f Compare December 25, 2021 14:36
Copy link
Member

@veehaitch veehaitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the plugin integration test. This is very helpful 🙏🏻

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@vtuan10
Copy link
Contributor Author

vtuan10 commented Dec 25, 2021

Added a check age-plugin in flake.nix.
The idea ist to build the example in rage and use the resulting age-plugin-unencrypted. The check tries to

  • "encrypt" according to secrets.nix
  • "decrypt" it with rage to check if the above worked
  • "rekey" it
    But currently it fails with failed to execute nix on both Linux and Darwin. Will look into it a bit more 😅

flake.nix Outdated Show resolved Hide resolved
@vtuan10 vtuan10 force-pushed the age-plugin-yubikey-integration branch 3 times, most recently from d49547c to 9413a18 Compare December 26, 2021 00:24
@vtuan10 vtuan10 marked this pull request as ready for review December 26, 2021 00:25
@vtuan10
Copy link
Contributor Author

vtuan10 commented Dec 26, 2021

Added a check age-plugin in flake.nix. The idea ist to build the example in rage and use the resulting age-plugin-unencrypted. The check tries to

* "encrypt" according to [secrets.nix](example/plugin-example/secrets.nix)

* "decrypt" it with `rage` to check if the above worked

* "rekey" it
  But currently it fails with `failed to execute nix` on both Linux and Darwin. Will look into it a bit more 😅

After requiring recursive-nix and setting the correct permission, it finally works

@vtuan10 vtuan10 force-pushed the age-plugin-yubikey-integration branch 2 times, most recently from aa033f7 to 579a991 Compare December 26, 2021 10:16
flake.nix Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
example/plugin-example/secrets.nix Outdated Show resolved Hide resolved
@vtuan10 vtuan10 force-pushed the age-plugin-yubikey-integration branch 16 times, most recently from 3dbef4b to f1184b9 Compare December 26, 2021 21:55
@vtuan10 vtuan10 force-pushed the age-plugin-yubikey-integration branch 6 times, most recently from 4de1ca6 to ba5a538 Compare December 26, 2021 23:34
@vtuan10 vtuan10 force-pushed the age-plugin-yubikey-integration branch from ba5a538 to ce9f77a Compare December 26, 2021 23:35
flake.nix Outdated
Comment on lines 140 to 143
# Symlink the plugins
for plugin in "${builtins.concatStringsSep " " plugins}"; do
ln -sf $plugin/bin/* $out/bin/
done
Copy link
Member

@veehaitch veehaitch Dec 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting approach! This wouldn't work, however, if the ragenix package itself isn't in PATH. I'd suggest wrapping the resulting binary if any plugins are given. Please see the commit I added.

@veehaitch veehaitch merged commit e233ec2 into main Dec 27, 2021
@veehaitch veehaitch deleted the age-plugin-yubikey-integration branch December 27, 2021 11:44
blaggacao pushed a commit to input-output-hk/ragenix that referenced this pull request Feb 18, 2022
* Add integration with rage plugins

* Update rage to v0.7.0

* Add age-plugin test

* Add plugin argument to ragenix

Co-authored-by: Vincent Haupert <[email protected]>
blaggacao pushed a commit to input-output-hk/ragenix that referenced this pull request Feb 18, 2022
* Add integration with rage plugins

* Update rage to v0.7.0

* Add age-plugin test

* Add plugin argument to ragenix

Co-authored-by: Vincent Haupert <[email protected]>
@pinpox
Copy link

pinpox commented Mar 11, 2022

Since this has been merged, how do I use my yubikey with ragenix?

@vtuan10
Copy link
Contributor Author

vtuan10 commented Mar 11, 2022

Since this has been merged, how do I use my yubikey with ragenix?

As the age-plugin-yubikey is added to nixpkgs now, use

nix shell nixpkgs#age-plugin-yubikey

to install it into your current session. Follow the instructions on age-plugin-yubikey to generate an identity.

Then enable the plugin in ragenix by overriding it to add the age-plugin-yubikey to the plugins. I'm not sure how you install ragenix, I have this in my configuraton.nix:

let
  ragenix-with-plugins = with pkgs; ragenix.override { plugins = [ age-plugin-yubikey ]; };
in
{
  environment.systemPackages = with pkgs; [
    ragenix-with-plugins
  ];
}

Now you can use the generated identity file as any other age identity file to decrypt secrets. To get the recipient for encryption run age-plugin-yubikey --list-all.

@veehaitch
Copy link
Member

Strictly speaking, bringing age-plugin-yubikey in scope (i.e., it's part of your PATH) is sufficient. ragenix will pick it up correctly even without overriding the derivation. Overriding is only useful if you don't usually have age-plugin-yubikey in your PATH.

@veehaitch
Copy link
Member

By the way, the manpage (man 1 ragenix) should also cover this: https://htmlpreview.github.io/?https://github.com/yaxitech/ragenix/blob/main/docs/ragenix.1.html#PLUGINS

@pinpox
Copy link

pinpox commented Mar 24, 2022

I just noticed there is no way to backup the identity when using that plugin, or am I mistaken? That is a bit concerning, loosing or destroying the yubikey would mean loosing access to the secrets?

@vtuan10
Copy link
Contributor Author

vtuan10 commented Mar 24, 2022

As far as I know, the age-plugin-yubikey does not officially state support for this. However there exists a comment how you can achieve this from the author of the plugin himself:

str4d/age-plugin-yubikey#39 (comment)

As far as this goes, I would suggest you create issues/feature requests on the plugin's site, as this does not really fall into ragenix's responsibilities.

@pinpox
Copy link

pinpox commented Mar 26, 2022

Thanks for the info. I'll have to think of a recovery strategy then, not sure yet where to go from here.

@vtuan10
Copy link
Contributor Author

vtuan10 commented Mar 26, 2022

Thanks for the info. I'll have to think of a recovery strategy then, not sure yet where to go from here.

Personally I suggest either buy a second yubikey or just generate a second age key, which you securely store on a separate usb stick

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.

3 participants