omegion / ssh-manager

SSH Key Manager for 1Password, Bitwarden and AWS S3.
https://ssh-manager.omegion.dev
Apache License 2.0
256 stars 8 forks source link

Doesn't work with 1Password CLI v2.x #77

Open edgar opened 2 years ago

edgar commented 2 years ago

Describe the bug 1Password released a v2.x of their CLI, and introduced breaking changes in the commands, for instance now the commands are something like:

op item list --categories login --tags SSHKeys

instead of what currently ssh-manager is expecting:

op list  items --categories login --tags SSHKeys

Below the error when trying to run ssh-manager list

❯ ssh-manager list --provider op
Error: 'op list': Execution failed: exit status 1: [ERROR] 2022/05/27 17:08:39 unknown command "list" for "op"
Usage:  op [command] [flags]

Management Commands:
  account     Manage your locally configured 1Password accounts
  connect     Manage Connect instances and Connect tokens in your 1Password account
  document    Perform CRUD operations on Document items in your vaults
  events-api  Manage Events API integrations in your 1Password account
  group       Perform CRUD operations on the groups of users in your 1Password account
  item        Perform CRUD operations on the 1Password items in your vaults
  user        Manage users within this 1Password account
  vault       Manage permissions and perform CRUD operations on your 1Password vaults

Commands:
  completion  Generate shell completion information
  inject      Inject secrets into a config file
  read        Read a secret using the secrets reference syntax
  run         Pass secrets as environment variables to a process
  signin      Sign in to a 1Password account
  signout     Sign out of a 1Password account
  update      Check for and download updates.

Global Flags:
      --account account    Select the account to execute the command by account shorthand, sign-in address, account ID, or user ID. For a list
                           of available accounts, run 'op account list'. Can be set as the OP_ACCOUNT environment variable.
      --cache              Store and use cached information.
      --config directory   Use this configuration directory.
      --debug              Output debug logs. Can also be set using $OP_DEBUG environment variable.
      --encoding type      Use this character encoding type. Default: UTF-8. Supported: SHIFT_JIS, gbk.
      --format string      Use this output format. Can be 'human-readable' or 'json'. Can be set as the OP_FORMAT environment variable.
                           (default "human-readable")
  -h, --help               Get help for op.
      --iso-timestamps     Format timestamps according to ISO 8601 / RFC 3339. Can be set as the OP_ISO_TIMESTAMPS environment variable.
      --no-color           Print output without color.
      --session token      Authenticate with this session token. 1Password CLI outputs session tokens for successful 'op signin' commands when
                           biometric unlock is disabled.

Run 'op [command] --help' for more information on the command.

To Reproduce Steps to reproduce the behavior:

  1. Install the new 1Password CLI
  2. Try to list/get a SSH Key using ssh-manager

Expected behavior Get/list the SSH Key items stored in 1Password

Environment:

omegion commented 2 years ago

We can support v1.x and v2.x together but it would require some work. Personally, I still use v1.x. I cannot assume everyone uses the new version.

edgar commented 2 years ago

Thanks for the quick response. I was thinking that probably an approach will be to to have a op2 provider, it seems most of the code will be the same just need to adjust the CLI params order. I can try to prepare a PR if you are interested

omegion commented 2 years ago

Feel free to create a PR for it, I would definitely contribute.