Improving the hygiene of 1Password CLI 2 integration account specification #1974
Replies: 10 comments 28 replies
-
Thanks very much for opening this discussion. Personally, I'm only using 1Password with a single (work) account so my knowledge of the details is much less than yours. This all sounds good. Note that on my machine running |
Beta Was this translation helpful? Give feedback.
-
What is the output of your |
Beta Was this translation helpful? Give feedback.
-
I also have |
Beta Was this translation helpful? Give feedback.
-
Well, ain’t that just peachy. So far, the 1Password folks seem to be ignoring my thread on 1password.community, but it appears that there is a difference in output for I am using biometric authentication (14" MBP with M1 Max), so the keys for the account list are The logic that I described is still sound with one tweak:
Shorthand overrides the collision detection mode because it is the well-known shorthand that should be used. We could also potentially add the first word before the What do you think? |
Beta Was this translation helpful? Give feedback.
-
I'm not sure it belongs here, but have noticed another caveat. My |
Beta Was this translation helpful? Give feedback.
-
Thank you @halostatue for providing such a detailed overview of the problem! I see quite a few friction points in this thread, so going to look and see if there's any changes we can make on the 1Password side to make this easier on your end. I'll get back to you all here. Cheers, Simon (Developer, Developer Products @ 1Password) |
Beta Was this translation helpful? Give feedback.
-
@SimonBarendse, the way that $ chezmoi execute-template "{{ onepasswordItemFields \"$UUID\" | toJson }}"
$ chezmoi execute-template "{{ onepasswordDocument \"$UUID\" }}" I use document fragments to construct my As long as op sees that my account has a computed (or set) shorthand of If I’m not using biometric authentication, then There’s at least two issues here:
It’s complex and messy and I’m probably not doing a great job of describing it, but these small changes by 1Password CLI have rippled into 3–4 different areas that require workarounds or fixes from 1Password. I’m not saying that all of the changes made are bad (I do think that requiring |
Beta Was this translation helpful? Give feedback.
-
Hi folks, I'm sorry for my slow replies here. I'm really strapped for time and I want this thread to receive the attention it deserves, so I have asked a teammate, @jkyjustin, to jump in here to help out. You're in great hands! |
Beta Was this translation helpful? Give feedback.
-
Hey @halostatue
Regarding this, yes the full URL can collide. One example of this is a 1Password employee testing across multiple CLI users on a single device - so when specifying the I believe of the two, |
Beta Was this translation helpful? Give feedback.
-
Opened draft #2425 for the 1Password account lookup behaviour. |
Beta Was this translation helpful? Give feedback.
-
The recent release of 1Password CLI 2.0.0 changes a number of things, but the two biggest changes are:
op signin
requires the--account
param. This has been fixed by Fixop signin
for v2 #1961 and chore: 1Password fixes #1966, although not yet released.op signin
without biometric authentication, the environment variable used is no longerOP_SESSION_<accountShorthand>
, butOP_SESSION_<accountUUID>
. That means that if I have an entry like{{ opDocument foo '' myaccount }}
, the session cannot be inherited from the environment because chezmoi will tryOP_SESSION_myaccount
, but the session token will actually be stored inOP_SESSION_myaccountUUID
. If1password.prompt
isfalse
, then the UUID is the only value that can be safely used inop*
template functions.A solution would be to cache the account maps at the beginning of a session (on the first call to any of the
op*
template functions). This would be retrieved withop account list --format=json
, which returns responses like this:I believe that this should be transformed into a lookup table with the following rules:
account1.1password.com
becomesaccount1
) is mapped to the UUID;The example given above would be transformed into the following (as JSON):
I believe that any of these values could be used to specify the
--account
parameter, but it would probably require testing to be sure.Collisions should be removed because they will result in ambiguous results. I believe that the order of
op accounts list --format=json
is stable, but is the reverse order of sign-in (that is, the first account is last in the list). Known collision cases would be:myaccount.1password.com
andmyaccount.1password.ca
ormyaccount.1password.eu
exist and the person has accounts on both (meaning that the short version of the URL would collide), OR[email protected]
exists in bothaccount1
andaccount2
.In theory, I guess it’s possible for the full URL to collide as well, but in that case, the email address would definitely not collide.
This doesn’t really affect me at the moment as I’m using biometric authentication, which is all kinds of awesome for chezmoi, but I think that it will be a problem for a fairly large class of users of 1Password CLI 2.0. I’m not sure how quickly this could be implemented, but I think that some sort of solution (as I’m not getting any feedback from Agilebits themselves) is necessary.
Beta Was this translation helpful? Give feedback.
All reactions