Secure Delegates with Tokens

Updated 2 months ago by Michael Cretzman

Delegate tokens are used by Harness to encrypt communication between Harness Delegates and the Harness Manager. By default, when a new Harness account is created, all Harness Delegates in that account include the same token.

You can further secure Delegate to Harness communication by replacing the default Delegate token with new tokens. You can add and revoke Delegate tokens per your governance policies and replace revoked tokens with custom tokens when needed.

In this topic:

Before You Begin

Step 1: Generate a New Token

You can generate a new token when you create a Delegate or as a separate process.

Generate a Token when Creating a Delegate

When you create a new Delegate, you can generate a new token.

In Delegate Setup, in Delegate Tokens, click Add, and then name and apply the new token:

The new token is created and its value is copied to your system clipboard. The new token also appears in the list using the name you gave it.

Save the new token value. You cannot retrieve the token value after this.

Now you can update the Delegate(s) with the new token.

In Delegate Tokens, select the new token.

Generate a Token without Creating a Delegate

In Harness, click Project Setup > Delegates in a Project or Account Settings > Account Resources > Delegates for the entire account.

Click Tokens. Here you can see, create, and revoke all Delegate tokens.

Click New Token.

Here's an Account Settings example:

Enter a name for the new token, and then click Apply.

You can copy the token and save it somewhere safe, if needed.

The new token is created and its value is copied to your system clipboard. The new token also appears in the list using the name you gave it.

Save the new token value. You cannot retrieve the token value after this.

When you install a new Delegate, you can select the token to use:

Option: Update and Restart Existing Delegate

You can update an existing Delegate with a new token value and then restart the Delegate.

Kubernetes Delegate

The Delegate is set up using the harness-delegate.yaml you downloaded originally.

Edit the harness-delegate.yaml you downloaded originally with the new token and then run kubectl apply -f harness-delegate.yaml to restart the Delegate pods.

Paste the token in the Delegate ACCOUNT_SECRET setting in the StatefulSet spec:

...
---

apiVersion: apps/v1
kind: StatefulSet
...
env:
...
- name: ACCOUNT_SECRET
value: [enter new token here]
...

Run kubectl apply -f harness-delegate.yaml

The Delegate pods get restarted automatically. The pods will restart and take the updated settings.

Docker Delegate

You will destroy and recreate the container using the docker-compose.yml you downloaded originally.

Paste the token in the Delegate settings:

version: "3.7"
services:
harness-ng-delegate:
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.5"
memory: 2048M
image: harness/delegate:latest
environment:
- ACCOUNT_ID=12345678910
- ACCOUNT_SECRET=[enter new token here]
- MANAGER_HOST_AND_PORT=https://app.harness.io
- WATCHER_STORAGE_URL=https://app.harness.io/public/pro
...

Create a new container: docker-compose -f docker-compose.yaml up -d.

You can verify that the environment variable has the new token using docker exec [container ID] env.

Option: Revoke Tokens

On the Tokens page, click Revoke to revoke any token.

Click Revoke. The token is revoked. The Harness Manager will not accept connections from any Delegates using this revoked token.


Please Provide Feedback