Project: external-secrets (Provisioning / Security & Compliance)
File: 1password-automation.md

External Secrets Operator integrates with for secret management. **The 1Password API calls the entries in vaults 'Items'. These docs use the same term.** How an Item is equated to an ExternalSecret: `remoteRef.key` is equated to an Item's Title `remoteRef.property` is equated to: An Item's field's Label (Password type) An Item's file's Name (Document type) If empty, defaults to the first file name, or the field labeled `password` `remoteRef.version` is currently not supported. One Item in a vault can equate to one Kubernetes Secret to keep things easy to comprehend. Support for 1Password secret types of `Password` and `Document`. The `Password` type can get data from multiple `fields` in the Item. The `Document` type can get data from files. See . Ordered vaults Specify an ordered list of vaults in a SecretStore and the value will be sourced from the first vault with a matching Item. If no matching Item is found, an error is returned. This supports having a default or shared set of values that can also be overriden for specific environments. `dataFrom`: `find.path` is equated to Item Title. `find.name.regexp` is equated to field Labels. `find.tags` are not supported at this time. 1Password requires running a 1Password Connect Server to which the API requests will be made. External Secrets does not run this server. See . One Connect Server is needed per 1Password Automation Environment. Many Vaults can be added to an Automation Environment, and Tokens can be generated in that Environment with access to any set or subset of those Vaults. 1Password Connect Server version 1.5.6 or higher. Authentication requires a `1password-credentials.json` file provided to the Connect Server, and a related 'Access Token' for the client in this provider to authenticate to that Connect Server. Both of these are generated by 1Password. Setup an Automation Environment , or . Note: don't be confused by the `op connect server create` syntax. This will create an Automation Environment in 1Password, and corresponding credentials for a Connect Server, nothing more. This will result in a `1password-credentials.json` file to provide to a Connect Server Deployment, and an Access Token to provide as a Secret referenced by a `SecretStore` or `ClusterSecretStore`. Create a Kubernetes secret with the Access Token ```yaml {% include '1password-token-secret.yaml' %} ``` Reference the secret in a SecretStore or ClusterSecretStore ```yaml {% include '1password-secret-store.yaml' %} ``` Create a Kubernetes secret with the Connect Server credentials ```yaml {% include '1password-connect-server-secret.yaml' %} ``` Reference the secret in a Connect Server Deployment ```yaml {% include

%} ``` Follow the remaining instructions in the . Deploy at minimum a Deployment and Service for a Connect Server, to go along with the Secret for the Server created in the . The Service's name will be referenced in SecretStores/ClusterSecretStores. Keep in mind the likely need for additional Connect Servers for other Automation Environments when naming objects. For example dev, staging, prod, etc. Unencrypted secret values are passed over the connection between the Operator and the Connect Server. Encrypting the connection is recommended.* Also see for matching SecretStore and ExternalSecret specs. Click the plus button to create a new Password type Item. Change the title to what you want `remoteRef.key` to be. Set what you want `remoteRef.property` to be in the field sections where is says 'label', and values where it says 'new field'. Click the 'Save' button. Click the plus button to create a new Document type Item. Choose the file to upload and upload it. Change the title to match `remoteRef.key` Click the 'Add New File' button to add more files. Click the 'Save' button. Create `file.json` with the following contents, swapping in your keys and values. Note: `section.name`'s and `section.title`'s values are ignored by the Operator, but cannot be empty for the `op` CLI ```json { "title": "my-title", "vault": { "id": "vault-id" }, "category": "LOGIN", "fields": [ { "id": "username", "type": "STRING", "purpose": "USERNAME", "label": "username", "value": "a-username" }, { "id": "password", "type": "CONCEALED", "purpose": "PASSWORD", "label": "password", "password_details": { "strength": "TERRIBLE" }, "value": "a-password" }, { "id": "notesPlain", "type": "STRING", "purpose": "NOTES", "label": "notesPlain", "value": "notesPlain" }, { "id": "customField", "type": "CONCEALED", "purpose": "custom", "label": "custom", "value": "custom-value" } ] } ``` Run `op item create --template file.json` Unfortunately the `op` CLI doesn't seem to support uploading multiple files to the same Item, and the current Go lib has a . `op` can be used to create a Document type Item with one file in it, but for now it's necessary to add multiple files to the same Document via the GUI. TL;DR if you need a field labeled `password`, use the in-built one rather than the one in a fields Section. 1Password automatically adds a field labeled `password` on every Password type Item, whether it's created through a GUI or the API or `op` CLI. There's no problem with using this field just like any other field, just make sure you don't end up with two fields with the same label. (For example, by automating the `op` CLI to create

The in-built `password` field is not otherwise special for the purposes of ExternalSecrets. It can be ignored when not in use. Examples of using the `my-env-config` and `my-cert` Items . Note: with this configuration a 1Password Item titled `my-env-config` is correlated to a ExternalSecret named `my-env-config` that results in a Kubernetes secret named `my-env-config`, all with matching names for the key/value pairs. This is a way to increase comprehensibility. ```yaml {% include '1password-secret-store.yaml' %} ``` ```yaml {% include '1password-external-secret-my-env-config.yaml' %} ``` ```yaml {% include '1password-external-secret-my-cert.yaml' %} ``` It's intuitive to use Document type Items for Kubernetes secrets mounted as files, and Password type Items for ones that will be mounted as environment variables, but either can be used for either. It comes down to what's more convenient. 1Password only supports version history on their in-built `password` field. Therefore, implementing version history in this provider would require one Item in 1Password per `remoteRef` in an ExternalSecret. Additionally `remoteRef.property` would be pointless/unusable. For example, a Kubernetes secret with 15 keys (say, used in `envFrom`,) would require 15 Items in the 1Password vault, instead of 15 Fields in 1 Item. This would quickly get untenable for more than a few secrets, because: All Items would have to have unique names which means `secretKey` couldn't match the Item name the `remoteRef` is targeting. Maintenance, particularly clean up of no longer used secrets, would be significantly more work. A vault would often become a huge list of unorganized entries as opposed to a much smaller list organized by Kubernetes Secret. To support new and old versions of a secret value at the same time, create a new Item in 1Password with the new value, and point some ExternalSecrets at a time to the new Item. One instance of the ExternalSecrets Operator can work with many Connect Server instances, but it may not be the best approach. With one Operator instance per Connect Server instance, namespaces and RBAC can be used to improve security posture, and perhaps just as importantly, it's harder to misconfigure something and have it work (supply env A's secret values to env B for example.) You can run as many 1Password Connect Servers as you need security boundaries to help protect against accidental misconfiguration. An overlay can provide a SecretStore specific to that overlay, and then use JSON6902 to patch all the ExternalSecrets coming from base to point to that SecretStore. Here's an example `overlays/staging/kustomization.yaml`: ```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: ../../base/something-with-external-secrets secretStore.staging.yaml patchesJson6902: target: kind: ExternalSecret name: ".*" patch: |- op: replace path: /spec/secretStoreRef/name value: staging ```