Problems with op v2 when integrating with chezmoi
I’ve recently upgraded to op v2, and it’s breaking chezmoi fairly hard. Even if the first issue is fixed (either in op or in chezmoi), there appear that there will be different errors based on whether biometric authentication is enabled or not.
Issues
op signin
protocol has changed for the worse. Previously, one could useop signin <account>
. Now, it is necessary to useop signin --account <account>
. This is a needless breaking change. It’s easy enough to work around with a version check. This is preventing the use of chezmoi on my machine at all because it cannot continue (I’m going to be submitting a patch; I’m annoyed that I have to do so).- Without biometric authentication:
op signin
emits a differentOP_SESSION_*
variable than it used to. The session variable used to be the account aliasOP_SESSION_<account>
. Now it'sOP_SESSION_<UUID>
, which means that anything that looked forOP_SESSION_<account>
will not find it, and because it cannot find the UUID, it will either prompt for login again or it will fail. Again, I feel like this is a needless breaking change. In the context of chezmoi, it means that I cannotop signin
before running chezmoi and will be asked for my password again. - With biometric authentication: no
OP_SESSION_*
variables are set. On the other hand, the biometric authentication just works.
1Password Version: 2.0.0
Extension Version: Not Provided
OS Version: Not Provided
Comments
-
Chezmoi has merged a patch that handles issue 1, although it has not yet been released (the likely version is 2.15.0).
Issue 2 is still going to be a problem, although the documentation will be updated to point out this issue. This may be able to be resolved in code if we can figure out how to use
op account list --format=json
to map the accounts properly. The loss of theOP_SESSION_<shorthand>
is fairly significant, though. It’d be nice if it could come back.0 -
I’ve started a discussion on a way that chezmoi could address issue 2. There are some questions that I have raised on that discussion which could use some input from Agilebits. https://github.com/twpayne/chezmoi/discussions/1974
0 -
Please note that there is a difference in output for
op account list --format=json
depending on whether biometric authentication is enabled. IMO, this is a bug.With biometric authentication enabled, the keys for the account list are
url
,email
, anduser_uuid
. With biometric authentication disabled, a new key (shorthand
) is now available. The lack ofshorthand
makes it harder to present a uniform data solution in chezmoi.0 -
Hey @austin,
Thank you for reaching out to us. Let's address these issues in order:
1.op signin
signature has changed - this has been done so by design. While all the other commands accepted the account filter through a flag,op signin
was the odd one out. This change came, in our opinion, to ensure consistency and intuitivity in the CLI, between different commands.
2. session token name changed - We tried, as much as possible, not to make this a breaking change. WhileOP_SESSION_<account_id>
is now set in the environment instead ofOP_SESSION_<shorthand>
, the CLI actually fetches the token from the latter envvar as well, if it cannot find the first one. Can you please elaborate a bit on your use-case here?
3. Indeed, noOP_SESSION_*
. You can find more details about biometric unlock here: https://developer.1password.com/docs/cli/biometric-security#technical-design
4. Different response forop account list --format json
- within biometric unlock, there is no such concept as an account shorthand. You can indeed use the first part of your sign-in address as an account filter, but that is different from an account shorthand. To state one difference, the user cannot modify that via the CLI.I get the feeling that there may be more questions within your messages, so please, do follow up and let us know how can we help you further!
Best,
Horia0 -
Most of the questions that are "within" my messages are detailed at https://github.com/twpayne/chezmoi/discussions/1974 and are specifically related to using 1Password with chezmoi, which is a dotfile management tool that can integrate with 1Password and other tools in order to retrieve secrets and documents so that they are not stored in your dotfile repository. Input from 1Password personnel on this discussion would be of great value.
An example of how this would be used would be something like this template where I fill my AWS credentials file from a combination of a static list in my
chezmoi.toml
configuration file and 1Password documents:{{- range .aws.credentials }} {{ if eq .type "1p" -}} {{ printf "# aws-credentials: %v (from %v %v %v)" .name .type .account .vault }} {{ onepasswordDocument (printf "aws-credentials: %v" .name) .vault .account }} {{- end -}} {{- end -}}
That would turn into something like
{{ onepasswordDocument "aws-credentials: personal" "Personal" "myaccount" }}
, which turns into anop
command that looks likeop document get 'aws-credentials: personal' --vault Personal --account myaccount
. If I my account is actually namedfoobarbaz
, but I had set the shorthandmyaccount
, I now have to change my configuration to either usefoobarbaz
or the UUID…if I’m using biometric authentication. Things get much harder if I’m not, because of the change to theOP_SESSION_*
variables.Now to address your responses:
- I disagree with your reasoning on this.
op signin <account-identifier>
is much the same asop document get <document-identifier>
, becauseop signin
is using the first parameter. It would be better, IMO, to make it such thatop signin
works without an identifier (signing into the last used account?), with an identifier (signing into the named account), or with--account identifier
. That is, if I have last signed intomyaccount
, thenop signin
,op signin myaccount
, andop signin --account myaccount
should all be equivalent. - Chezmoi reads from
OP_SESSION_<shorthand>
and has no way to look upOP_SESSION_<account_id>
, so the change fromOP_SESSION_<account_id>
toOP_SESSION_<shorthand>
is a breaking change, because the session can no longer be retrieved by the shorthand name which has been (optionally) used in the templates. This will force everyone to change their account identifier to the UUID. (The discussion mentioned at the top is a way that we can possibly work around this.) - No issues with the biometric item missing
OP_SESSION_*
. Everything just works. - The missing shorthand may be a breaking change for people who had different shorthands than their account names. Its presence would be ideal, and again this is discussed in depth in the Github discussion linked above.
0 - I disagree with your reasoning on this.
-
Hi @austin, I'm sorry about 1) the friction you're having upgrading to v2 and 2) our slow response. I'm engaging in the GitHub discussion now and exploring what we can do on our end to take away friction points. I already said it on the GitHub thread and I will say so again: thanks so much for the overview and detail in your communication both here and in the GitHub discussion!
0 -
I disagree with your reasoning on this. op signin
is much the same as op document get , because op signin is using the first parameter. It would be better, IMO, to make it such that op signin works without an identifier (signing into the last used account?), with an identifier (signing into the named account), or with --account identifier. That is, if I have last signed into myaccount, then op signin, op signin myaccount, and op signin --account myaccount should all be equivalent. I think the biggest difference with
op document get <identifier>
and friends is that they already specify the resource name in the parent command: "document". I think the equivalent for signin would be:op account signin <account>
.Now that you're prompted to sign-in on other commands and signin is no longer a required action to perform before any other command, it may become an option to consider moving
signin
andsignout
underop account
(we'd continue to support the root-level invocations for backwards-compatibility).0