Artifact Routing Rules¶
What are artifact routing rules?¶
Requests made to a group repository will loop over the ordered repositories1 list to resolve
the artifact
.
The first repository which has the artifact
will serve it to the client.
Artifact Routing Rules allows you to fine-tune which of the ordered repositories1 can accept
or deny
the URL
pattern. This makes it possible to narrow down the list of repositories1 which will be used to resolve
the artifact.
Types of routing rules¶
Accepted¶
Allowed routing rules are used to allow resolving the artifact/path from the accepted repositories2.
By default all ordered repositories1 will accept
any url pattern. Therefore, this rule is only useful when
it is used with a deny
rule.
Denied¶
Denied routing rules are used to block
resolving the artifact/path from the denied repositories3.
Artifact Routing Rules precedence¶
An accepted
rule takes precedence over denied
.
Consider the following example:
- You have configured a pattern to
deny
the pattern.*/org/.*
for all ordered repositories1 inmyGroupRepository
- You have configured a pattern to
accept
the pattern.*/org/carlspring/strongbox/.*
viamyRepository
inmyGroupRepository
In this case, if myGroupRepository
has myRepository
in the ordered repositories1, then the request .*/org/carlspring/strongbox/.*
will be allowed.
So, if you want to exclude some artifact (or artifacts matching some pattern), then make sure any accepted rule does not match the same pattern.
Artifact Routing Rules optionality¶
Routing rules may be strict or elastic, in two ways.
Flexibility of defining the group repository¶
- We can define the specific group repository (by identifying its
storage-id
andrepository-id
) - We can define the group repositories within declared
storage-id
(by leavingrepository-id
empty) - We can define the group repositories having provided
repository-id
(by leavingstorage-id
empty)
Flexibility of defining the underlying repositories¶
- We can define the specific underlying repository (by identifying its
storage-id
andrepository-id
) - We can define the underlying repositories within declared
storage-id
(by leavingrepository-id
empty) - We can define the underlying repositories having provided
repository-id
(by leavingstorage-id
empty)
The above approaches can be used together and separately.
Examples¶
Accepted Patterns¶
The following example specifies that:
- Requests for artifacts matching
^(com|org)/corp/foo.*
will be accepted by every repository withrepository-id
equal tothird-party-releases
under each group havingrepository-id
equal togroup-releases
. - Requests for artifacts matching
^(com|org)/carlspring/strongbox.*
will be accepted by repository identified bystorage-id
equal tostorage-common-proxies
andrepository-id
equal toreleases
under each group of repositories.
Example:
<configuration>
...
<routing-rules>
<routing-rule uuid="0f84a9a7-b2ce-47ed-8a01-085e235a1942"
storage-id=""
repository-id="group-releases"
pattern="^(com|org)/corp/foo.*"
type="accept">
<repositories>
<repository storage-id="" repository-id="third-party-releases"/>
</repositories>
</routing-rule>
<routing-rule uuid="0f84a9a7-b2ce-47ed-8a01-085e235a1943"
storage-id=""
repository-id=""
pattern="^(com|org)/carlspring/strongbox.*"
type="accept">
<repositories>
<repository storage-id="storage-common-proxies" repository-id="releases"/>
</repositories>
</routing-rule>
</routing-rules>
</configuration>
Denied Patterns¶
- The following example disable lookups for
.*(com|org)/carlspring.*
in the group repository identified bystorage-id
equal tostorage-common-proxies
andrepository-id
equal togroup-common-proxies
in the underlying repository identified bystorage-id
equal tostorage-common-proxies
andrepository-id
equal tojboss-public-releases
.
To put it more simply, if someone tries to access .*(com|org)/carlspring.*
from group repository storage-id="storage-common-proxies" repository-id="group-common-proxies"
then this group repository won't serve this request from repository storage-id="storage-common-proxies" repository-id="jboss-public-releases"
, for sure.
<configuration>
...
<routing-rules>
<routing-rule uuid="0f84a9a7-b2ce-47ed-8a01-085e235a1946"
storage-id="storage-common-proxies"
repository-id="group-common-proxies"
pattern=".*(com|org)/carlspring.*"
type="deny">
<repositories>
<repository storage-id="storage-common-proxies" repository-id="jboss-public-releases"/>
</repositories>
</routing-rule>
</routing-rules>
</configuration>
- The following example disable lookups for
.*(com|org)/carlspring.*
inrepository-id="jboss-public-releases"
for every group repository containing this repository.
<configuration>
...
<routing-rules>
<routing-rule uuid="0f84a9a7-b2ce-47ed-8a01-085e235a1947"
storage-id=""
repository-id=""
pattern=".*(com|org)/carlspring.*"
type="deny">
<repositories>
<repository storage-id="" repository-id="jboss-public-releases"/>
</repositories>
</routing-rule>
</routing-rules>
</configuration>
-
Ordered Repositories List - an ordered list of repositories which you configure when you add the group repository. ↩↩↩↩↩↩
-
Accepted Repositories - are an ordered list of Accepted repositories. If these repositories are in your Group Repository, then they will be used to
resolve
the artifact. ↩ -
Denied Repositories - are an ordered list of Denied repositories. If these repositories are in your Group Repository, then they will NOT be used to
resolve
the artifact. ↩