Skip to content

Commit 0b6b2c0

Browse files
Copilottheoephraim
andauthored
feat: Support 1Password Connect server in 1Password plugin (#533)
* Initial plan * feat: add 1Password Connect server support Add a new auth mode for self-hosted 1Password Connect servers using connectHost + connectToken parameters in @initOp(). Uses direct REST API calls via native fetch - no op CLI or 1Password SDK required. Includes: - Connect REST API integration with vault/item/field resolution - op:// reference parsing for Connect API lookups - Vault and item ID caching within a session - New opConnectToken data type - Clear error for opLoadEnvironment (not supported with Connect) - Updated README with Connect server documentation - Changeset for minor version bump Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/6fa88b02-ac93-4548-adfb-94a31cd5ac69 Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com> * fix: escape double quotes in Connect API filter queries Prevent potential filter syntax issues if vault/item names contain double quotes by escaping them before constructing filter expressions. Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/6fa88b02-ac93-4548-adfb-94a31cd5ac69 Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com> * fix: escape backslashes in Connect API filter queries Address CodeQL incomplete-sanitization alert by escaping backslashes before quotes in filter expressions to prevent filter injection. Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/6fa88b02-ac93-4548-adfb-94a31cd5ac69 Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com> * refactor: prefix Connect-only helper methods/fields with "connect" Rename private members of OpPluginInstance to make it immediately clear they are only relevant to the Connect server auth mode: - vaultIdCache → connectVaultIdCache - resolveVaultId → connectResolveVaultId - itemIdCache → connectItemIdCache - resolveItemId → connectResolveItemId - extractField → connectExtractField Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/85435a8e-c00e-4d7e-9660-8b6966e6f017 Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com> * downgrade to patch bump this is purely additive functionality --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com> Co-authored-by: Theo Ephraim <theo@dmno.dev>
1 parent 74752a3 commit 0b6b2c0

3 files changed

Lines changed: 300 additions & 13 deletions

File tree

.changeset/brave-doors-connect.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@varlock/1password-plugin": patch
3+
---
4+
5+
Add support for 1Password Connect server (self-hosted)
6+
7+
- New auth mode: `connectHost` + `connectToken` parameters in `@initOp()` for connecting to self-hosted 1Password Connect servers
8+
- Direct REST API integration — no `op` CLI or 1Password SDK required for Connect server usage
9+
- New `opConnectToken` data type for Connect server API tokens
10+
- Parses standard `op://vault/item/[section/]field` references and resolves them via the Connect API
11+
- Caches vault and item ID lookups within a session for efficiency
12+
- Clear error when `opLoadEnvironment()` is used with Connect (not supported by the Connect API)
13+
- Updated error messages and tips to include Connect server as an auth option

packages/plugins/1password/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This package is a [Varlock](https://varlock.dev) [plugin](https://varlock.dev/gu
88

99
- **Service account authentication** for CI/CD and production environments
1010
- **Desktop app authentication** for local development (with biometric unlock support)
11+
- **Connect server authentication** for self-hosted 1Password infrastructure
1112
- **Secret references** using 1Password's standard `op://` format
1213
- **Bulk-load environments** with `opLoadEnvironment()` via `@setValuesBulk`
1314
- **Multiple vault support** for different environments and access levels
@@ -89,6 +90,31 @@ When enabled, if the service account token is empty, the plugin will use the des
8990
Keep in mind that this method connects as _YOU_ who likely has more access than a tightly scoped service account. Consider only enabling this for non-production secrets.
9091
:::
9192

93+
### Connect server setup (self-hosted)
94+
95+
If you are running a self-hosted [1Password Connect server](https://developer.1password.com/docs/connect/), you can authenticate using a Connect server URL and token:
96+
97+
```env-spec
98+
# @plugin(@varlock/1password-plugin)
99+
# @initOp(connectHost="http://connect-server:8080", connectToken=$OP_CONNECT_TOKEN)
100+
# ---
101+
102+
# @type=opConnectToken @sensitive
103+
OP_CONNECT_TOKEN=
104+
```
105+
106+
**Setup requirements:**
107+
108+
1. Deploy a [1Password Connect server](https://developer.1password.com/docs/connect/get-started/)
109+
2. Create a Connect token with access to the required vault(s)
110+
3. Set the `OP_CONNECT_TOKEN` environment variable
111+
112+
This method uses the Connect server REST API directly — no `op` CLI or 1Password SDK is required.
113+
114+
:::note
115+
The `opLoadEnvironment()` function is not supported with Connect server auth. Use `op()` to read individual items instead.
116+
:::
117+
92118
### Multiple instances
93119

94120
If you need to connect to multiple accounts or vault configurations, register multiple named instances:
@@ -173,6 +199,8 @@ Initialize a 1Password plugin instance - setting up options and authentication.
173199
- `token?: string` - Service account token. Should be a reference to a config item of type `opServiceAccountToken`.
174200
- `allowAppAuth?: boolean` - Enable authenticating using the local desktop app (defaults to `false`)
175201
- `account?: string` - Limits the `op` CLI to connect to specific 1Password account (shorthand, sign-in address, account ID, or user ID)
202+
- `connectHost?: string` - URL of a self-hosted 1Password Connect server (e.g., `http://connect-server:8080`)
203+
- `connectToken?: string` - API token for the Connect server. Should be a reference to a config item of type `opConnectToken`. Required when `connectHost` is set.
176204
- `id?: string` - Instance identifier for multiple instances (defaults to `_default`)
177205

178206
### Functions
@@ -203,6 +231,7 @@ Load all variables from a 1Password environment. Intended for use with `@setValu
203231
### Data Types
204232

205233
- `opServiceAccountToken` - 1Password service account token (sensitive, validated format)
234+
- `opConnectToken` - API token for a self-hosted 1Password Connect server (sensitive)
206235

207236
---
208237

@@ -262,6 +291,12 @@ Note that [rate limits](https://developer.1password.com/docs/service-accounts/ra
262291
- Check that you specified the correct account (run `op account list`)
263292
- Try running `op whoami` to debug CLI connection
264293

294+
### Connect server errors
295+
- Verify the Connect server URL is correct and the server is running
296+
- Check that the Connect token has access to the required vault(s)
297+
- Ensure the Connect server version supports the vaults and items you're accessing
298+
- Try accessing `<connectHost>/v1/vaults` directly to verify connectivity
299+
265300
### Rate limiting
266301
- Check your account type's rate limits
267302
- Consider implementing caching or reducing request frequency
@@ -271,6 +306,7 @@ Note that [rate limits](https://developer.1password.com/docs/service-accounts/ra
271306

272307
- [1Password](https://1password.com/)
273308
- [Service Accounts](https://developer.1password.com/docs/service-accounts/)
309+
- [1Password Connect](https://developer.1password.com/docs/connect/)
274310
- [1Password CLI](https://developer.1password.com/docs/cli/)
275311
- [Secret References](https://developer.1password.com/docs/cli/secret-references/)
276312
- [Full documentation](https://varlock.dev/plugins/1password/)

0 commit comments

Comments
 (0)