You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: deployment/nuget-keys.md
+51-71Lines changed: 51 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,105 +8,85 @@ position: 6
8
8
9
9
# Restoring NuGet Packages in Your CI Workflow
10
10
11
-
This article provides an overview of the most popular approaches for using token-based authentication to restore Telerik NuGet packages in your CI (Continuous Integration) workflow.
11
+
This article describes how to use token-based authentication for the Telerik NuGet feed. You will learn how to create and use NuGet API keys to restore Telerik NuGet packages in your Continuous Integration (CI) workflow.
12
12
13
-
The Telerik NuGet server allows you to authenticate by using two methods:
13
+
When you need to restore the [Telerik NuGet packages](slug:getting-started/what-you-need#nuget-packages) as part of your CI, using API Keys provides a secure way to authenticate. This method does not require you to provide your Telerik credentials anywhere in the CI workflow. An API key has a limited scope and can be used only with the Telerik NuGet server. If any of your API Keys is compromised, you can quickly delete it and create a new one.
14
14
15
-
* Basic authentication by providing your Telerik user name and password.
16
-
* Token-based authentication by providing a NuGet Key.
15
+
## Generating API Keys
17
16
18
-
When you need to restore Telerik NuGet packages as part of your CI, using NuGet keys is the more secure way to authenticate. This method does not require you to provide your Telerik username and password anywhere in the CI workflow.
17
+
As the Telerik NuGet server requires authentication, the first step is to obtain an API key that you will use instead of a password. Using an API key instead of a password is a more secure approach.
19
18
20
-
Unlike your Telerik credentials, a NuGet Key has a limited scope and can be used only with the Telerik NuGet server. If any of your NuGet keys is compromised, you can quickly delete it and create a new one.
19
+
1. Go to the [API Keys](https://www.telerik.com/account/downloads/api-keys) page in your Telerik account.
20
+
1. Click **Generate New Key +**.
21
+
1. In the **Key Note** field, add a note that describes the API key.
22
+
1. Click **Generate Key**.
23
+
1. Select **Copy and Close**. Once you close the window, you can no longer copy the generated key. For security reasons, the **API Keys** page displays only a portion of the key.
24
+
1. Store the generated NuGet API key as you will need it in the next steps. Whenever you need to authenticate your system with the Telerik NuGet server, use `api-key` as the username and your generated API key as the password.
21
25
22
-
## Generating NuGet Keys
26
+
## Storing API Keys
23
27
24
-
1. Go to the [**Manage NuGet Keys**](https://www.telerik.com/account/downloads/nuget-keys) page in your Telerik account.
28
+
>warning Never check in NuGet API keys with your source code or leave them publicly visible in plain text (for example, in a `NuGet.Config` file). An API key is valuable and bad actors can use it to access the NuGet packages that are licensed under your account. A key abuse can lead to a review of the affected Telerik account.
To protect the API key, store it as a secret environment variable. The exact store steps depend on your workflow and environment:
27
31
28
-
1. To create a new key, select the **Generate New Key** button.
32
+
* In GitHub Actions, save the key as a [GitHub Actions Secret](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions).
33
+
* In Azure DevOps, save the key as a [secret Azure DevOps pipeline variable](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-secret-variables). If you use an Azure DevOps Service connection instead of secret environment variables, enter `api-key` in the username field and the API key as the password in the **New NuGet service connection** form editor.
34
+
* In Docker images, save the key as a [Docker secret](https://docs.docker.com/tags/secrets/).
29
35
30
-
1. Enter a name for the NuGet Key, and then select **Generate Key**.
36
+
For more details on storing and protecting your API key, check the [Announcing NuGet Keys](https://www.telerik.com/blogs/announcing-nuget-keys) blog post by Lance McCarthy.
31
37
32
-
1. To copy the key, select **Copy and Close**. Once you close the window, you can no longer copy the generated key. For security reasons, the **NuGet Keys** page displays only a portion of the key.
38
+
The examples below assume that the secret environment variable name is `TELERIK_NUGET_KEY`.
> Never check in a NuGet Key with your source code or leave it publicly visible in plain text, for example, as a raw key value in a `nuget.config` file. A NuGet Key is valuable as bad actors can use it to access the NuGet packages that are licensed under your account. A potential key abuse could lead to a review of the affected account.
43
+
There are two common ways to use a [stored API key](#storing-api-keys) with the Telerik NuGet server during a build:
39
44
40
-
To protect the NuGet Key, store it as a secret environment variable. The exact steps depend on your workflow:
45
+
*[Use a NuGet.Config file](#using-a-nuget-config-file)
46
+
*[Use only CLI commands](#using-net-cli-commands)
41
47
42
-
* In GitHub Actions, save the key as a GitHub Actions Secret. Go to **Settings** > **Security** > **Secrets** > **Actions** > **Add new secret**.
48
+
For more information on how to use API keys in a build, check the [Announcing NuGet Keys](https://www.telerik.com/blogs/announcing-nuget-keys) blog post by Lance McCarthy.
43
49
44
-
* In Azure DevOps Classic, save the key as a secret pipeline variable. Go to the **Variables** tab and then select **Pipeline variables**.
50
+
### Using a NuGet.Config File
45
51
46
-
*In Azure DevOps YAML pipelines, save the key as a secret variable as well. Click the YAML editor's **Variables** button and complete the **New variable** form.
52
+
In your `NuGet.Config` file, set the `Username` value to `api-key` and the `ClearTextPassword` value to an environment variable name:
47
53
48
-
If you use Azure DevOps Service connection instead of secret environment variables, enter `api-key` in the username filed and the NuGet Key as the password in the **New NuGet service connection** form editor.
54
+
<divclass="skip-repl"></div>
49
55
50
-
For more details on storing and protecting your NuGet Key, check the [Announcing NuGet Keys](https://www.telerik.com/blogs/announcing-nuget-keys) blog post by Lance McCarthy.
There are two popular ways to use the Telerik NuGet server in a build:
55
-
56
-
*[Using a nuget.config file with your projects](#using-a-nugetconfig-file-with-your-projects)
57
-
58
-
*[Using only CLI commands](#using-only-cli-commands)
59
-
60
-
For more information on how to use NuGet keys in a build, check the [Announcing NuGet Keys](https://www.telerik.com/blogs/announcing-nuget-keys) blog post by Lance McCarthy.
61
-
62
-
### Using a nuget.config File with Your Projects
63
-
64
-
1. In your `nuget.config` file, set the `Username` value to `api-key` and the `ClearTextPassword` value to an environment variable name:
1. Set the `MY_API_KEY` environment variable by using the value of your pipeline/workflow secret.
84
-
85
-
The exact steps to set the `MY_API_KEY` environment variable depend on your workflow. For more details, refer to the [Announcing NuGet Keys](https://www.telerik.com/blogs/announcing-nuget-keys) blog post by Lance McCarthy.
86
-
87
-
### Using Only CLI Commands
88
-
89
-
You can use the CLI `add source` (or `update source`) command to set the credentials of a package source. This CLI approach is applicable if your CI system doesn't support default environment variable secrets or if you do not use a custom `nuget.config`.
75
+
You can use the .NET CLI `add source` or `update source` commands to set the credentials of a package source. This CLI approach is applicable if your CI system doesn't support [environment variable secrets](#storing-api-keys) or if you do not [use a custom `NuGet.Config`](#using-a-nuget-config-file).
If you just start using the Telerik NuGet server in your CI or inter-department workflows, check the two blog posts below. You will learn about the various use cases and find practical implementation details.
106
-
107
-
* [Azure DevOps and Telerik NuGet Packages](https://www.telerik.com/blogs/azure-devops-and-telerik-nuget-packages)
> When restoring NuGet packages through the CLI, [use `dotnet restore` rather than `nuget restore` to avoid compatibility errors](slug:common-kb-package-telerik-pivot-not-compatible-with-netframework).
0 commit comments