Skip to content

Routing rules

The routing rules functionality is available in Enterprise and Atlas versions.

What is a routing rule

A routing rule defines which packages are allowed or prohibited from being downloaded through a proxy repository.

The rule checks the package name against specified wildcard patterns and makes a decision on whether the package can be downloaded.

Depending on the configured mode, the rule:

  • blocks the download of packages that match the specified patterns;
  • allows the download only of packages that match the specified patterns.

Routing rules are used to control packages obtained from external registries via the proxying mechanism.

Where routing rules are applied

Routing rules can be applied:

  • to proxy repositories of a registry;
  • to external registries of the common package registry.

A created rule can only be assigned to a proxy repository.

Only one routing rule can be used for a single proxy repository.

How a routing rule works

Each rule operates in one of two modes:

Mode Description
Blocking rule Blocks the download of packages whose names match the specified wildcard patterns
Allowing rule Allows the download only of those packages whose names match the specified wildcard patterns

The rule mode is set by a toggle switch when configuring the rule.

When accessing an external registry, the application checks the package name against the rule assigned to the proxy repository.

The check result depends on the rule mode:

Mode Name matches pattern Name does not match pattern
Blocking rule Download prohibited Download allowed
Allowing rule Download allowed Download prohibited

Wildcard patterns

Wildcard patterns are used to configure rules.

A wildcard pattern is an expression with special characters that allows describing several package names with a single string.

Symbol Description Example pattern Example matching package name
* Matches a sequence of characters internal-* internal-library
? Matches a single character package-? package-a
** Matches a sequence of characters, including path elements group/** group/project/package

The set of patterns is interpreted according to the selected rule mode: as a list of prohibited or allowed package names.

Creating a routing rule

The list of routing rules is available from the registry settings.

To navigate to the list of routing rules:

  1. Open the registry page.
  2. Select Settings.

To create a routing rule:

  1. Open the routing rules list page.
  2. Select Create rule.
  3. Specify the rule mode using the toggle switch:
  4. blocking rule;
  5. allowing rule.
  6. Specify wildcard patterns for checking package names.
  7. Complete the rule creation.

After creation, the rule becomes available for assignment to a proxy repository.

Testing a rule

On the rule editing page, it is possible to test the operation of the wildcard patterns.

The test allows you to determine whether a specific package would be allowed or prohibited for download when using the current rule.

To test a rule:

  1. Open the routing rule editing page.
  2. Check the selected rule mode.
  3. Specify or modify the wildcard patterns.
  4. Enter the package name for testing.
  5. Run the test.

After the test, the application displays the resolution:

Resolution Description
Allowed Package download is allowed by the current rule
Prohibited Package download is prohibited by the current rule

The test result depends on the selected rule mode and whether the package name matches the specified wildcard patterns.

Applying a rule to a registry repository

A routing rule can only be applied to a proxy type repository.

A proxy repository is used to obtain packages from an external registry. If a routing rule is assigned to the repository, the requested package name is checked before proxying.

To apply a rule to a registry repository:

  1. Open the registry repository creation or editing page.
  2. Ensure that the proxy repository type is selected.
  3. Select the created routing rule.
  4. Complete the repository creation or save its changes.

After assignment, the rule is used when downloading packages through this proxy repository.

Only one routing rule can be assigned to a single proxy repository.

Applying a rule to the common package registry

Routing rules can be applied to external registries of the common package registry.

To apply a rule:

  1. Open the External registries page.
  2. Open the creation or editing of an external registry.
  3. Select the created routing rule.
  4. Complete the external registry creation or save its changes.

After assignment, the rule is used when proxying packages through the corresponding external registry.

Retrieving packages from the cache

If caching is enabled for a proxy repository and the requested package is already in the registry, the cached version of the package is returned.

In this case, access to the external registry is not required, so the preconditions for proxying are not checked.

If the requested package is not in the cache, proxying is performed to obtain it from the external registry. Before proxying, the conditions specified in the Preconditions for proxying section are checked.

Preconditions for proxying

If the requested package is not in the cache, the following conditions must be met for successful proxying of the package with the application a transport token with write permissions to the registry is configured;

Automated translation!

This page has been automatically translated. The text may contain inaccuracies.