> ## Documentation Index
> Fetch the complete documentation index at: https://docs.endorlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure Package Firewall credentials for CI/CD

> <Badge color="green">Beta</Badge> <br /> Store your Package Firewall API key and API secret as CI/CD secrets, and configure uv, npm, pnpm, Poetry, and Bundler to install through Package Firewall in your pipelines.

When you resolve dependencies with Package Firewall configured as your index, your package manager writes the Package Firewall URL for your namespace into the lockfile. Every package then resolves through Endor Labs instead of the canonical registry. Installs that replay that lockfile need Package Firewall credentials, so pipeline commands such as `npm ci`, `uv sync --locked`, and `poetry install` return `401 Unauthorized` until you supply them.

Store your Package Firewall credentials as CI/CD secrets, then configure each package manager client to read them from environment variables. Your pipelines authenticate without committing credentials to your repository.

> [!WARNING]
>
> Lockfiles can embed Package Firewall URLs, such as the encoded `.npmrc` authentication npm uses or the authenticated index URLs uv and Poetry write. These lockfiles break installs for anyone without credentials to your namespace, including forks and repositories shared with other organizations. Regenerate the lockfile against the canonical registry before you share the repository outside your organization.

## Before you begin

Make sure you have the following:

* A Package Firewall API key and API secret. See [Configure the Package Firewall with direct integration](https://docs.endorlabs.com/package-firewall/direct-integration.md#create-an-api-key-for-the-package-firewall) to create them.
* A package manager configuration file that points at Package Firewall. See [Configure the Package Firewall with direct integration](https://docs.endorlabs.com/package-firewall/direct-integration.md#configure-your-package-manager-configuration-file) to generate one with the configuration wizard.

> [!NOTE]
>
> If you use Endor Labs with an EU tenant, use `https://factory.eu.endorlabs.com` instead of `https://factory.endorlabs.com`.

## Store Package Firewall credentials as CI/CD secrets

Store your Package Firewall API key and API secret as secrets in your CI/CD system, such as repository or runner secrets. Expose them to pipeline jobs as environment variables. Don't write credentials directly in pipeline steps or commit them to your repository.

The following table maps each package manager configuration file to the environment variables it reads. The uv and Poetry variable names derive from the `endor-firewall` index or source name used in the following sections.


&#x20; \- Configuration\_file: \`.npmrc\` (npm, pnpm, and Yarn Classic)
&#x20; Environment\_variables: \`NPM\_AUTH\`
&#x20; Value: Base64 encoding of \`\<api-key>:\<api-secret>\`
&#x20; Reference: \[npm CI/CD documentation]\(https\://docs.npmjs.com/using-private-packages-in-a-ci-cd-workflow#set-the-token-as-an-environment-variable-on-the-cicd-server)

&#x20; \- Configuration\_file: \`pyproject.toml\` or \`uv.toml\` (uv)
&#x20; Environment\_variables: \`UV\_INDEX\_ENDOR\_FIREWALL\_USERNAME\` and \`UV\_INDEX\_ENDOR\_FIREWALL\_PASSWORD\`
&#x20; Value: API key and API secret
&#x20; Reference: \[uv environment variable reference]\(https\://docs.astral.sh/uv/reference/environment/#uv\_index\_name\_password)

&#x20; \- Configuration\_file: \`pyproject.toml\` (Poetry)
&#x20; Environment\_variables: \`POETRY\_HTTP\_BASIC\_ENDOR\_FIREWALL\_USERNAME\` and \`POETRY\_HTTP\_BASIC\_ENDOR\_FIREWALL\_PASSWORD\`
&#x20; Value: API key and API secret
&#x20; Reference: \[Poetry repositories documentation]\(https\://python-poetry.org/docs/repositories/)

&#x20; \- Configuration\_file: \`\~/.bundle/config\` (Bundler)
&#x20; Environment\_variables: \`BUNDLE\_FACTORY\_\_ENDORLABS\_\_COM\`
&#x20; Value: URL-encoded \`\<api-key>:\<api-secret>\`
&#x20; Reference: \[Bundler configuration documentation]\(https\://bundler.io/man/bundle-config.1.html)
&#x20;&#x20;

To store secrets and map them to environment variables, refer to the documentation for your CI/CD system, for example [GitHub Actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions), [GitLab CI/CD](https://docs.gitlab.com/ci/variables/), [Azure DevOps](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-secret-variables), [CircleCI](https://circleci.com/docs/guides/security/env-vars/), [Jenkins](https://www.jenkins.io/doc/book/using/using-credentials/), or [Harness](https://developer.harness.io/docs/platform/secrets/add-use-text-secrets/).

## Configure uv for CI/CD

When you run `uv lock` with Package Firewall configured, uv writes the firewall URL, including your namespace, into `uv.lock`. Every package resolves through Endor Labs instead of a canonical PyPI source.

Since the lockfile references authenticated firewall URLs, reproducible installs fail in CI/CD when [credentials](https://docs.endorlabs.com/package-firewall/direct-integration.md#create-an-api-key-for-the-package-firewall) to `factory.endorlabs.com` are absent. uv commands that require a connection to the lockfile URLs, such as `uv sync --locked` or `uv sync --frozen`, return `401 Unauthorized` unless credentials are provided.

To install from the lockfile in CI/CD without committing credentials to your repository, give your index a name and pass the credentials as environment variables.

1. In your existing uv index in `pyproject.toml` or `uv.toml`, add a name and remove the credentials from the URL. uv matches credentials to an index by this name.

   > [accordion] pyproject.toml
   >
   > ```toml theme={null}
   > [[tool.uv.index]]
   > name = "endor-firewall"
   > url = "https://factory.endorlabs.com/v1/namespaces/<your-namespace>/firewall/pypi/simple/"
   > default = true
   > ```

   > [accordion] uv.toml
   >
   > ```toml theme={null}
   > [[index]]
   > name = "endor-firewall"
   > url = "https://factory.endorlabs.com/v1/namespaces/<your-namespace>/firewall/pypi/simple/"
   > default = true
   > ```

2. In your CI/CD system, store the credentials as secrets and expose them to jobs as the following environment variables. uv derives the variable names from the index name in uppercase, so `endor-firewall` becomes `ENDOR_FIREWALL`. For more information, refer to the [uv environment variable reference](https://docs.astral.sh/uv/reference/environment/#uv_index_name_password).

   * `UV_INDEX_ENDOR_FIREWALL_USERNAME`: Your Package Firewall API key.
   * `UV_INDEX_ENDOR_FIREWALL_PASSWORD`: Your Package Firewall API secret.

## Configure npm for CI/CD

When you run `npm install` with Package Firewall configured, npm writes the firewall URL, including your namespace, into `package-lock.json`. Every package resolves through Endor Labs instead of a canonical npm registry.

Since the lockfile references firewall URLs, reproducible installs fail in CI/CD when [credentials](https://docs.endorlabs.com/package-firewall/direct-integration.md#create-an-api-key-for-the-package-firewall) to `factory.endorlabs.com` are absent. Commands that install from the lockfile, such as `npm ci`, return `401 Unauthorized` unless credentials are provided.

To install from the lockfile in CI/CD without committing credentials to your repository, keep the registry URL in `.npmrc` and pass the encoded credentials as an environment variable.

1. In the project `.npmrc` file, set the Package Firewall registry and read `_auth` from an environment variable.

   ```ini theme={null}
   registry=https://factory.endorlabs.com/v1/namespaces/<your-namespace>/firewall/npm/
   //factory.endorlabs.com/v1/namespaces/<your-namespace>/firewall/npm/:_auth=${NPM_AUTH}
   always-auth=true
   ```

2. Generate the Base64 encoding of `<api-key>:<api-secret>` with your Package Firewall API key and API secret. This is the same encoding as the configuration wizard.

   ```bash theme={null}
   printf '%s' "<api-key>:<api-secret>" | base64 | tr -d '\n'; echo
   ```

3. In your CI/CD system, store the encoded value as a secret and expose it to jobs as the `NPM_AUTH` environment variable. For more information, refer to the [npm CI/CD documentation](https://docs.npmjs.com/using-private-packages-in-a-ci-cd-workflow#set-the-token-as-an-environment-variable-on-the-cicd-server).

## Configure pnpm for CI/CD

pnpm reads the same `.npmrc` registry as npm. When that file points at Package Firewall, `pnpm install` and `pnpm add` go through Endor Labs. By default, `pnpm-lock.yaml` stores integrity hashes and does not store tarball URLs.

Set the same `.npmrc` credentials in CI/CD as you do for npm. See [Configure npm for CI/CD](#configure-npm-for-ci/cd) to set `NPM_AUTH`. Commands such as `pnpm install --frozen-lockfile` then resolve through Package Firewall.

If the [`lockfile-include-tarball-url`](https://pnpm.io/settings) setting is `true`, pnpm writes Firewall tarball URLs into `pnpm-lock.yaml`. Reproducible installs then return `401 Unauthorized` when credentials to `factory.endorlabs.com` are absent.

## Configure Yarn Classic for CI/CD

Yarn Classic (v1) writes the Package Firewall tarball URL for each package, including your namespace, into the `resolved` field of `yarn.lock`. Commands that install from the lockfile, such as `yarn install --frozen-lockfile`, fail without credentials. Package Firewall returns `401 Unauthorized`, but Yarn Classic reports it as a missing package:

```text theme={null}
error Couldn't find package "<package>" on the "npm" registry.
```

Yarn Classic reads credentials from `.npmrc`, so set the same credentials in CI/CD as you do for npm. See [Configure npm for CI/CD](#configure-npm-for-ci/cd) to set `NPM_AUTH`.

## Configure Poetry for CI/CD

When you run `poetry lock` with Package Firewall set as a source, Poetry writes the Firewall URL, including your namespace, into `poetry.lock`. Every package resolves through Endor Labs instead of a canonical PyPI source.

Since the lockfile references firewall URLs, reproducible installs fail in CI/CD when [credentials](https://docs.endorlabs.com/package-firewall/direct-integration.md#create-an-api-key-for-the-package-firewall) to `factory.endorlabs.com` are absent. Commands that install from the lockfile, such as `poetry install`, return `401 Unauthorized` unless credentials are provided.

To install from the lockfile in CI/CD without committing credentials to your repository, keep the source URL in `pyproject.toml` and pass the credentials as environment variables.

1. In `pyproject.toml`, add the Package Firewall source with a name and no credentials in the URL. Poetry matches credentials to a source by this name.

   ```toml theme={null}
   [[tool.poetry.source]]
   name = "endor-firewall"
   url = "https://factory.endorlabs.com/v1/namespaces/<your-namespace>/firewall/pypi/simple/"
   priority = "primary"
   ```

2. In your CI/CD system, store the credentials as secrets and expose them to jobs as the following environment variables. Poetry derives the variable names from the source name in uppercase, so `endor-firewall` becomes `ENDOR_FIREWALL`. For more information, refer to the [Poetry repositories documentation](https://python-poetry.org/docs/repositories/).

   * `POETRY_HTTP_BASIC_ENDOR_FIREWALL_USERNAME`: Your Package Firewall API key.
   * `POETRY_HTTP_BASIC_ENDOR_FIREWALL_PASSWORD`: Your Package Firewall API secret.

## Configure Bundler for CI/CD

Bundler does not write the Package Firewall URL into `Gemfile.lock`, so installations in CI/CD do not fail without credentials. Without the Package Firewall mirror, they download gems directly from `rubygems.org`, and Package Firewall does not check them.

To route installations in CI/CD through Package Firewall, set the mirror in your pipeline and pass the credentials as an environment variable.

1. Run the following commands to encode your API key and API secret for use in a URL. This is the same encoding as the configuration wizard.

   ```bash theme={null}
   printf '%s\n' "<api-key>" | sed -e 's/+/%2B/g' -e 's#/#%2F#g' -e 's/=/%3D/g'
   printf '%s\n' "<api-secret>" | sed -e 's/+/%2B/g' -e 's#/#%2F#g' -e 's/=/%3D/g'
   ```

2. In your CI/CD system, store `<encoded-api-key>:<encoded-api-secret>` as a secret and expose it to jobs as the `BUNDLE_FACTORY__ENDORLABS__COM` environment variable. Bundler reads credentials for a host from a variable named `BUNDLE_` followed by the host in uppercase, with each period replaced by two underscores and each hyphen by three underscores. If you use an EU tenant, name the variable `BUNDLE_FACTORY__EU__ENDORLABS__COM` and use `factory.eu.endorlabs.com` in the mirror URL in the next step. For more information, refer to the [Bundler configuration documentation](https://bundler.io/man/bundle-config.1.html).

3. Add the following command to your pipeline before `bundle install`.

   ```bash theme={null}
   bundle config set --global mirror.https://rubygems.org/ https://factory.endorlabs.com/v1/namespaces/<your-namespace>/firewall/gem/
   ```

## Next steps

* Configure which packages the firewall flags and how it responds. See [Package Firewall policy](https://docs.endorlabs.com/package-firewall/policy.md) to learn more.
* Review the events the firewall records. See [View Package Firewall logs](https://docs.endorlabs.com/package-firewall/logs.md) to learn more.

<draft>
  ## Troubleshooting and FAQ

  > [accordion] Why does Poetry return 401 errors when my environment variables are set?
  >
  > The variables aren't in your current shell scope. On Windows, set them with `[System.Environment]::SetEnvironmentVariable` using the `User` scope, then restart your terminal. For a single session, you can set `$env:POETRY_HTTP_BASIC_ENDOR_FIREWALL_USERNAME` and `$env:POETRY_HTTP_BASIC_ENDOR_FIREWALL_PASSWORD` in PowerShell instead.
</draft>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.