Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added docs for migrating encrypted secrets #30132

Merged
merged 24 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5785fc6
docs: new doc for Mend App secrets and secrets migration
justo-mend Jun 9, 2024
d318ed9
docs: minor formatting updates to App Secrets doc
justo-mend Jun 9, 2024
351ebf3
docs: updated with prettier fixes
justo-mend Jun 9, 2024
9105bf7
docs: updated 'Encrypting secrets' of Private Packages page. Secrets …
justo-mend Jun 9, 2024
7296c7c
docs: formatting changes to secrets documentation
justo-mend Jun 9, 2024
8e252ea
docs: split secrets docs into separate pages for basic usage and migr…
justo-mend Jun 10, 2024
275dacb
docs: updated with prettier fixes
justo-mend Jun 10, 2024
dd62cf1
docs: updated secrets migration guied
justo-mend Jul 11, 2024
3fdf7f4
docs: updated secrets migration guide
justo-mend Jul 11, 2024
3277af4
docs: updated secrets migration guide
justo-mend Jul 11, 2024
16f376c
docs: updated secrets migration guide
justo-mend Jul 11, 2024
16f8b91
Merge pull request #1 from justo-mend/docs/using-app-secrets
justo-mend Jul 11, 2024
5aedba7
Merge pull request #2 from renovatebot/main
justo-mend Jul 11, 2024
87584ee
docs: updated lint fixes
justo-mend Jul 11, 2024
9097cd1
docs: updated lint fixes
justo-mend Jul 11, 2024
56a4323
Merge remote-tracking branch 'origin/main'
justo-mend Jul 11, 2024
4c45861
docs: updated with prettier fixes
justo-mend Jul 11, 2024
668053a
docs: removed referenced to "Developer Portal"
justo-mend Jul 11, 2024
58f628d
docs: updated with review comments
justo-mend Jul 11, 2024
d4833e0
Apply suggestions from code review
rarkins Jul 20, 2024
a15ed4e
Update migrating-secrets.md
rarkins Jul 20, 2024
b02c498
Update migrating-secrets.md
rarkins Jul 20, 2024
7de930d
Merge branch 'main' into main
rarkins Jul 20, 2024
16b25d2
Update docs/usage/getting-started/app-secrets.md
rarkins Jul 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions docs/usage/getting-started/app-secrets.md
justo-mend marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Using Secrets with Mend Cloud Apps
rarkins marked this conversation as resolved.
Show resolved Hide resolved

The Mend-hosted cloud apps - Renovate App on GitHub, Mend App on Bitbucket - have deprecated the use of encrypted secrets in Renovate config files stored in the repo.
Instead, secrets for the cloud apps must be stored in the app settings using the web UI available at [developer.mend.io](http://developer.mend.io).

## How to use secrets in the Mend Hosted Cloud Apps
rarkins marked this conversation as resolved.
Show resolved Hide resolved

To use secrets in the Mend Cloud apps:
rarkins marked this conversation as resolved.
Show resolved Hide resolved

1. Add the secret in the **Credentials** section of the [Developer Portal](http://developer.mend.io) Org or Repo settings.
justo-mend marked this conversation as resolved.
Show resolved Hide resolved

![Credentials settings page](../assets/images/app-settings/app-credentials.png)

2. Reference the secret from Renovate config files inside the repo.

```json
{
"hostRules": [
{
"matchHost": "github.com",
"token": "{{ secrets.MY-ORG-SECRET-1 }}"
}
]
}
```

## Org secrets versus Repo secrets
rarkins marked this conversation as resolved.
Show resolved Hide resolved

When adding a secret in the Developer Portal UI, check whether you are adding **Organization secrets** or **Repository secrets**.

- Org-level secrets will be inherited by all repos in the org.
- Repo-level secrets can be referenced by only the specific repo.

![Org and Repo secrets](../assets/images/app-settings/org-and-repo-secrets.png)

This image shows credentials from the Repo settings page. It shows inherited Organisation Secrets, plus the specific Repository Secrets.
Only the Repo settings can be edited here. Org settings must be edited in the Org settings page.

- **To access Org-level secrets**, press the `Settings` button on the Org page.<br/>
_Tip: You know you are on the Org page if you see the **Installed Repositories** table._

![Org settings button](../assets/images/app-settings/org-settings-button.png)

- **To access Repo-level secrets**, press the `Settings` button on the Repo page.<br/>
_Tip: You know you are on a Repo page if you see the **Recent jobs** table._

![Repo settings button](../assets/images/app-settings/repo-settings-button.png)

## Related links

rarkins marked this conversation as resolved.
Show resolved Hide resolved
- [Migrating encrypted secrets from Repo Config to App Settings](migrating-secrets.md)
rarkins marked this conversation as resolved.
Show resolved Hide resolved
93 changes: 93 additions & 0 deletions docs/usage/getting-started/migrating-secrets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Migrating Secrets from Repo Config to App Settings

Storing of encrypted secrets in the repo is not supported starting from 01-Sep-2024 for Mend Renovate Cloud apps.
justo-mend marked this conversation as resolved.
Show resolved Hide resolved
Previously, secrets used in the App would be encrypted using the [Renovate encryption tool](https://app.renovatebot.com/encrypt) and stored in Renovate config files.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
Now all secrets must be stored in the App settings on the cloud.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
They can be referenced from the Renovate config files inside the repo using `{{ secrets.SECRET_NAME }}` notation.

**Example - Deprecated version**: Encrypted secrets included in Renovate config
rarkins marked this conversation as resolved.
Show resolved Hide resolved

rarkins marked this conversation as resolved.
Show resolved Hide resolved
```json
rarkins marked this conversation as resolved.
Show resolved Hide resolved
{
"hostRules": [
{
"matchHost": "github.com",
"encrypted": {
"token": "drsMDVf6M2hTZCN......+gQm/0Rpw"
}
}
]
}
```

**Example - Supported version**: Reference App secrets from the Renovate config
rarkins marked this conversation as resolved.
Show resolved Hide resolved

rarkins marked this conversation as resolved.
Show resolved Hide resolved
```json
rarkins marked this conversation as resolved.
Show resolved Hide resolved
{
"hostRules": [
{
"matchHost": "github.com",
"token": "{{ secrets.GITHUB_COM_TOKEN }}"
}
]
}
```

> [!NOTE]
>
> When migrating encrypted secrets, we recommend copying over the existing secrets in their _**encrypted form**_. The UI will handle the decryption and store the value securely.
> Avoid trying to change the secret during migration, as this will introduce an additional potential point of failure.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

## To migrate encrypted secrets using the encrypted value
rarkins marked this conversation as resolved.
Show resolved Hide resolved

1. Copy the encrypted secret from the Renovate config file.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

2. Go to the settings for the correct Org or Repo in the web UI at [http://developer.mend.io](http://developer.mend.io).
rarkins marked this conversation as resolved.
Show resolved Hide resolved

3. In the **Credentials** page, press `ADD SECRET` to add the encrypted secret.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

4. Provide a value for `Secret name`, put the encrypted secret in the `Secret Value` field, and press `SAVE`.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

> [!NOTE]
>
> When migrating an existing secret from a repo, be sure to add the secret to the same Org or Repo for which the secret was generated.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
>
> - A secret generated for a specific repo cannot be added to a different repo.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
> - A secret generated for a specific repo cannot be added to the Org settings. It can only be added into Repo settings for the matching repo.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
> - A secret generated without a specific repo can be added into Org or Repo settings in the matching org.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

The settings UI will provide helpful information if you try to add the secret in the wrong place.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

![Migrating secrets error](../assets/images/app-settings/encrypted-secrets-error.png)

5. Look for the confirmation box to say **“Successfully migrated secret”** to confirm that the secret was correctly decrypted and stored in the correct Org or Repo.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

![Successfully migrated secret](../assets/images/app-settings/stored-secret-encrypted.png)

> [!IMPORTANT]
>
> If the confirmation box does not say **“Successfully migrated secret”**, and instead says **“Successfully stored secret”** then the secret was not detected as a Renovate encrypted secret and the value was treated as plain text.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
> If you were expecting to import a secret originally encrypted by Renovate:
>
> - Make sure you are using the secret in the correct Org and/or Repo.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
> - Check that you copied the encrypted secret correctly, and try again.

## To migrate encrypted secrets using the plain text value

1. Go to the settings for the correct Org or Repo in the web UI at [http://developer.mend.io](http://developer.mend.io).
rarkins marked this conversation as resolved.
Show resolved Hide resolved

2. In the **Credentials** page, press `ADD SECRET` to add the plain text secret.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

![Add repo secret](../assets/images/app-settings/add-repo-secret.png)

3. Provide a value for `Secret name`, put the secret in the `Secret Value` field, and press `SAVE`.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

![Add a Secret dialog box](../assets/images/app-settings/add-a-secret.png)

4. Look for a confirmation dialog showing **“Successfully stored secret”**.
rarkins marked this conversation as resolved.
Show resolved Hide resolved

![Successfully stored secret](../assets/images/app-settings/stored-secret-plaintext.png)

## Related links

- [Using Secrets with Mend Cloud Apps](app-secrets.md)
44 changes: 23 additions & 21 deletions docs/usage/getting-started/private-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -585,30 +585,32 @@ The solution to this is that you should break your presets into public and priva
It is strongly recommended that you avoid committing secrets to repositories, including private ones, and this includes secrets needed by Renovate to access private modules.
The preferred approach to secrets is that the bot administrator configures them as `hostRules` which are then applied to all repositories which the bot accesses.

> [!IMPORTANT]
>
> Use of encrypted secrets in Renovate config has been deprecated in the Mend Renovate App. Secrets must now be stored in the App settings via the web UI.
>
> For more information, see [Migrating Secrets from Repo Config to App Settings](migrating-secrets.md)
rarkins marked this conversation as resolved.
Show resolved Hide resolved

If you need to provide credentials to the Mend Renovate App, please do this:

- Encrypt each secret string using <https://app.renovatebot.com/encrypt>. Note: this encrypts using the app's public key fully in the browser and does not send the original secret to any server. You can download this file and perform the encryption fully offline if you like.
- Wrap each secret field in an [encrypted](../configuration-options.md#encrypted) object and paste in the encrypted secret value instead. An example is shown below:
1. Add each secret string in the Credentials section of Organisation or Repository settings [Developer Portal](https://developer.mend.io/) web UI.

```json
{
"hostRules": [
{
"matchHost": "registry.npmjs.org",
"encrypted": {
"token": "3f832f2983yf89hsd98ahadsjfasdfjaslf............"
}
},
{
"matchHost": "https://custom.registry.company.com/pypi/",
"username": "bot1",
"encrypted": {
"password": "p278djfdsi9832jnfdshufwji2r389fdskj........."
}
}
]
}
```
![Organisation and Repository secrets in Credentials settings page](../assets/images/app-settings/org-and-repo-secrets.png)
rarkins marked this conversation as resolved.
Show resolved Hide resolved

2. Reference secrets inside your Renovate config files with notation: `{{ secrets.YOUR_SECRET }}`.

```json
{
"hostRules": [
{
"matchHost": "github.com",
"token": "{{ secrets.GITHUB_COM_TOKEN }}"
}
]
}
```

For more details, see [Using Secrets with Mend Cloud Apps](app-secrets.md).

### Access to GitHub Actions Secrets

Expand Down
Loading