# Guide to Secret Management

Secret Utility (secretutil) is a password management tool used to store, manage, and retrieve passwords. Secret Utility returns the passwords in plain text.

The following sections describe the configuration of Secret Utility, which is installed as part of the Clarity LIMS-SecretUtil RPM.

## Installing Integration Packages on Clarity LIMS

You may refer to the integration package installation guide for more information on installing/configuring the integration package.

## Configuration Script

If Secret Utility has not been configured, the **05\_configure\_claritylims\_secretutil.sh** script is created in the **/opt/gls/clarity/config/pending** folder.

**To reconfigure Secret Utility**:

1. Remove the hidden file **/opt/gls/clarity/tools/secretutil/.configured**
2. Run the Secret Utility configuration script as follows: **/opt/gls/clarity/config/configure\_claritylims\_secretutil.sh**

The following table describes the entries prompted by the **configure\_claritylims\_secretutil.sh** script.

### **Configuration Script Entries**

| **Prompts**                                                                                                                                                                                                                                                                                                                                          | **Default** | **Description**                                                                                                                                                                                                                                                                                           |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enter required value for Secret Utility Mode.                                                                                                                                                                                                                                                                                                        | vault       | Configure the mode for Secret Utility. Allowed values: vault, file                                                                                                                                                                                                                                        |
| Enter required value for Clarity Tenant Hostname.                                                                                                                                                                                                                                                                                                    | localhost   | <p><strong>Vault mode only</strong><br>Configure the Tenant hostname to be used as part of the vault path.</p>                                                                                                                                                                                            |
| Enter required value for Vault Engine Path.                                                                                                                                                                                                                                                                                                          | secret      | <p><strong>Vault Mode only</strong><br>Configure the secret engine path.</p>                                                                                                                                                                                                                              |
| Enter required value for Vault URI.                                                                                                                                                                                                                                                                                                                  |             | <p><strong>Vault Mode only</strong><br>Configure the Vault Server target.</p>                                                                                                                                                                                                                             |
| Vault Enterprise (Y/N)                                                                                                                                                                                                                                                                                                                               | N           | <p><strong>Vault Mode only</strong><br>Configure whether the Vault Server is an enterprise version.</p>                                                                                                                                                                                                   |
| Enter required value for Vault Namespace.                                                                                                                                                                                                                                                                                                            |             | <p><strong>Vault Enterprise only</strong><br>Configure the Vault namespace.</p>                                                                                                                                                                                                                           |
| Enter required value for Vault Authentication Mode.                                                                                                                                                                                                                                                                                                  |             | <p><strong>Vault Mode only</strong><br>Configure the authentication method. Allowed values: token, approle</p>                                                                                                                                                                                            |
| Enter required value for Vault Token.                                                                                                                                                                                                                                                                                                                |             | **Token Authentication only**                                                                                                                                                                                                                                                                             |
| Enter required value for Vault AppRole Role-Id.                                                                                                                                                                                                                                                                                                      |             | <p><strong>AppRole Authentication only</strong><br>Configure the AppRole role-id to use. Refer to Role ID noted during HashiCorp Vault configuration. (See <a data-mention href="../../on-premise-deployments/pre-installation-requirements/configure-your-hashicorp-vault#approle">#approle</a>)</p>     |
| Enter required value for Vault AppRole Secret-Id.                                                                                                                                                                                                                                                                                                    |             | <p><strong>AppRole Authentication only</strong><br>Configure the AppRole secret-id to use. Refer to Secret ID noted during HashiCorp Vault configuration. (See <a data-mention href="../../on-premise-deployments/pre-installation-requirements/configure-your-hashicorp-vault#approle">#approle</a>)</p> |
| <p>Enter required value for app.ftp.password<br>Enter required value for app.ldap.managerPass<br>Enter required value for app.rabbitmq.password<br>Enter required value for db.tenant.password<br>Enter required value for db.clarity.password<br>Enter required value for db.lablink.password<br>Enter required value for db.reporting.password</p> |             | <p><strong>File Mode only</strong><br>Sets the secrets (encrypted with <strong>CLARITYSECRET\_ENCRYPTION\_KEY env variable</strong>) into <strong>conf/secret.properties</strong></p>                                                                                                                     |
| <p><strong>Global values</strong><br>Enter required value for platform.clientid (optional for integration with Platform Auth)</p>                                                                                                                                                                                                                    |             | <p><strong>File Mode only</strong><br>Sets the secrets (encrypted with <strong>CLARITYSECRET\_ENCRYPTION\_KEY env variable</strong>) into <strong>conf/secret.properties</strong></p>                                                                                                                     |
| Enter required value for Username for API user                                                                                                                                                                                                                                                                                                       | apiuser     | <p><strong>File Mode only</strong><br>Sets the username of the API user to be used when applications require an API user.</p>                                                                                                                                                                             |
| Enter required password for API user                                                                                                                                                                                                                                                                                                                 |             | <p><strong>File Mode only</strong><br>Sets the password for the API user configured.</p>                                                                                                                                                                                                                  |

## Managing the passwords (Vault Mode)

If Secret Utility is configured as Vault Mode, the passwords are stored and retrieved from Vault Enterprise.

* To use Secret Utility and perform the following steps, you must first remote into the instance before performing any of the following steps.
* To use the Vault user interface (UI) and perform the following steps, you must have the appropriate role and access control list (ACL) policies.

<details>

<summary>Vault ACL Paths</summary>

The Vault ACLs control three main paths: Clarity, Integration, and Ops. If there is an attempt to write into a read-only path, **secretutil.jar** returns an error.

**Clarity (read only)**

* Stores all passwords related to Clarity LIMS. The secrets/passwords are encrypted with **CLARITYSECRET\_ENCRYPTION\_KEY env variable**. See [#configuration-script](#configuration-script "mention").

**Integration (read write)**

* Stores all integration-related passwords and allows read and write access.
* apiusers
  * Stores passwords that are used by packages and applications for API authentication (eg, the apiuser password).
  * Username is case sensitive.
  * For example, retrieve apiuser password from **integration/apiusers/apiuser**.
* external.file.stores
  * Stores password of external file stores used by Clarity LIMS.
  * External file store is optional to the Clarity LIMS system.
  * For example, retrieve file store password from **integration/external.file.stores/.password**.

**Ops**

* Stores secrets related to operations.
  * For **Illumina cloud hosted deployments**, Illumina manages this path.
  * This path is optional for **on-premise** customers.

</details>

<details>

<summary>Create a New Password</summary>

**Using Secret Utility**

The following command creates a new password:

```
java -jar /opt/gls/clarity/tools/secretutil/secretutil.jar [-gh] [-n=<namespace>] [-u=<newValue>] <key>
```

* When creating a new password for integration, specify the -n= integration option.
* Make sure that the key uses a forward slash for nested secrets. For example, **apiusers/apiuser**
* The same command is used for updating an existing password and creating a new password. Read the key you are planning to create to check whether it is an existing password.

Example (Creating new password for external file store):

```
java -jar /opt/gls/clarity/tools/secretutil/secretutil.jar -n=integration -u=<password> external.file.stores/<external file store name>.password 
```

**Using Vault UI**

1. Log in to the Vault UI.
2. Select the Key Value (KV) secret engine with the path `instances`.
3. Look for the FQDN instance that you want to create the password for.
4. Select the path where you want to create the new password, ie, **clarity/integration/ops**.
5. Select **Create Secret +**.
6. Under **Path for this secret**, enter the path for the new password, eg, **app.ldap.managerPass**.
7. Under **Version data**:
   1. Enter 'value' into the **key** field.
   2. Enter the new password into the **value** field.
8. Select **Save**.

</details>

<details>

<summary>Read an Existing Password</summary>

**Using Secret Utility**

Run the following command to create a new password:

```
java -jar /opt/gls/clarity/tools/secretutil/secretutil.jar <key>
```

**Using Vault UI**

1. Log in to the Vault UI.
2. Select the KV secret engine with the path **instances**.
3. Look for the FQDN instance that you want to create the password for.
4. Select the path where the existing password is located, ie, **clarity/integration/ops**.
5. Click into the secret and view the password by selecting the peek icon.

</details>

<details>

<summary>Update an Existing Password</summary>

**NOTE**: Global values can be updated through Vault UI only.

**Using Secret Utility**

Run the following command to update an existing password:

```
java -jar /opt/gls/clarity/tools/secretutil/secretutil.jar [-gh] [-n=<namespace>] [-u=<newValue>] <key>
```

**Using Vault UI**

1. Log in to the Vault UI.
2. Select the KV secret engine with the path **instances**.
3. Look for the FQDN instance that you want to create the password for.
4. Select the path where the existing password is located, ie, **clarity/integration/ops**.
5. Select into the secret.
6. Select **Create new version +**.
7. Under **Version Data**, enter the new password.
8. Select **Save**.

</details>

<details>

<summary>Delete an Existing Password</summary>

**NOTE**: Confirm with the Illumina Support team before deleting passwords and secrets.

**Using Secret Utility**

Secret Utility does not support permanent deletion of a key by design.

**Using Vault UI**

1. Log in to the Vault UI.
2. Select the KV secret engine with the path **instances**.
3. Look for the FQDN instance that you want to create the password for.
4. Select the path, ie, **clarity/integration/ops**, to the location of the existing password.
5. Select into the secret.
6. Select **Delete secret**.

</details>

## Managing the Passwords (File Mode)

If Secret Utility is configured as File mode, the passwords are encrypted and stored in **/opt/gls/clarity/tools/secretutil/conf/secrets.properties**. Encryption is based on the **CLARITYSECRET\_ENCRYPTION\_KEY** environment variable.

To manage the passwords and perform the following steps, you must first remote into the instance.

<details>

<summary>Create a New Password</summary>

Run the following command to create a new password:

```
java -jar /opt/gls/clarity/tools/secretutil/secretutil.jar [-gh] [-n=<namespace>] [-u=<newValue>] <key>
```

* If you are creating a new password for integration, specify the -n=integration option.
* The same command is used for updating an existing password and creating a new password. Read the key you are planning to create to check whether it is an existing password.

Example (Creating new password for external file store):

```
java -jar /opt/gls/clarity/tools/secretutil/secretutil.jar -n=integration -u=<password> external.file.stores/<external file store name>.password 
```

</details>

<details>

<summary>Read an Existing Password</summary>

Run the following command to read an existing password:

```
java -jar /opt/gls/clarity/tools/secretutil/secretutil.jar <key>
```

</details>

<details>

<summary>Update an Existing Password</summary>

**NOTE**: Global values can only be updated through secret utility in File Mode.

Run the following command to update an existing password:

```
java -jar /opt/gls/clarity/tools/secretutil/secretutil.jar [-gh] [-n=<namespace>] [-u=<newValue>] <key>
```

</details>

<details>

<summary>Delete an Existing Password</summary>

**NOTE**: Confirm with the Illumina Support team before deleting passwords and secrets.

By design, Secret Utility does not support permanent deletion of a key. As an alternative, you can run the following steps.

1. Open the *secrets.properties* file with an editor, eg, vim.
2. Remove the key from the file and save the file.

</details>
