1Password integration for Emacs.
- Call
opfrom Emacs without repeated authentication prompts - Read secrets anywhere via
op-read - Use 1Password as an
auth-sourcebackend
Using the 1Password CLI (op) inside Emacs is annoying:
- It may re-request authentication on every call
- There's no simple way to fetch secrets inline
- Emacs packages still expect
.authinfoorpass
This package fixes all of that.
Requires Emacs 29.1+ and the 1Password CLI (op).
(use-package op
:vc (:url "https://github.com/renatgalimov/op.el" :branch "main"))(use-package op-auth-source
:vc (:url "https://github.com/renatgalimov/op.el" :branch "main")
:config
(op-auth-source-enable))Clone the repository and add it to your load-path:
(add-to-list 'load-path "/path/to/op.el")
(require 'op)The op-auth-source package provides an auth-source backend so that Emacs packages like smtpmail, Gnus, ERC, and others can fetch credentials from 1Password automatically.
(require 'op-auth-source)
(op-auth-source-enable)This adds 1password to your auth-sources list. Emacs will then consult 1Password when any package calls auth-source-search.
Tag the items you want Emacs to access with emacs-auth-source in 1Password. The backend only searches items with this tag.
Items are matched by their fields. The backend maps each search criterion to one or more field labels:
| Criterion | Matched field labels |
|---|---|
:host |
host, server, hostname |
:user |
user, username, email |
:port |
port, port number |
Any other criterion key is matched against a field whose label equals the key name (e.g., :security matches a field labeled security).
A search must include at least one non-nil criterion; an empty search returns no results.
When a package searches for credentials (e.g., :host "smtp.gmail.com" :user "alice@gmail.com" :port 587), the backend:
- Runs
op item list --tags emacs-auth-source --format jsonto find tagged items - Fetches full item details via
op item get - Matches each criterion against the item's fields by label
- Returns the password via
op item get <id> --fields label=password
(op-auth-source-disable)Write unit tests with Buttercup and name each spec using the pattern X when Y should Z.
Install the development dependencies with Cask and run the suite via ./scripts/run-tests.sh before submitting a pull request.
