Updates to `pyonepassword`

zcutlipzcutlip Junior Member

I've made a few updates to my pyonepassword project.

It now has first-class support for many of 1Password "item" types, including:

  • Login
  • Credit Card
  • Secure Note
  • Password
  • Document
  • Server

Each of these object types has convenience properties for the default fields in their respective templates.

Also, all item types have a few convenience methods for accessing sections and their respective fields, which can otherwise be a bit messy. This helps with pulling custom section data out of item objects:

def field_value_by_section_title(self, section_title: str, field_label: str)
def first_section_by_title(self, title) -> OPSection
def sections_by_title(self, title) -> List[OPSection]

There's a script in the examples directory of pulling an SSH keypair out of a server object and writing the public & private key to disk:
https://github.com/zcutlip/pyonepassword/blob/master/examples/server-ssh-keys.py

I actually use this one a fair bit myself when I set up a new laptop. On an existing system, I create the keys and ssh-copy-id them wherever they need to go. I then put them into 1Password using the op command with a template. Then on the new laptop, part of my move-in automation uses pyonepassword to pull the keys out of 1Password and drop them in ~/.ssh/ so I can start logging into servers right away.

It's still read-only, so adding/updating/deleting items isn't yet possible.

You can pip install pyonepassword or check out the source at:
https://github.com/zcutlip/pyonepassword

I hope it's useful to someone!

Zach

ps I admit to not having caught up with the fancy new secrets automation stuff, so someone kindly let me know if that makes pyonepassword no longer relevant

Comments

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file