Overview
I manage a Nexus 3 OSS version (3.30.1-01) that has multiple companies uploading their dependencies to their own repositories. There are certain dependencies within their repositories that should be accessible by other companies, while keeping everything else private. I have read through all the documentation, scoured the internet for articles covering this topic, and read Nexus developer articles covering how to implement this. However, I have not been able to get Content Selectors working to solve this problem.
Desired Result
When Company A adds a dependency from Company B’s hosted repository to their Maven pom.xml
file and they have the appropriate read access, the build should complete properly as it locates the dependency in Company A’s group repository. If Company A adds a dependency from Company B’s hosted repository to their Maven pom.xml
file they do not have access to, it should fail stating that Maven could not locate the dependency from Company A’s group repository.
Repositories
This section will give a general overview of the repositories and their contents for both Company A and Company B.
Company A has the following repositories:
companyA-maven-group
- companyA-maven-hosted (hosts all of Company A's dependencies they create)
- companyB-maven-hosted (provide read access to Company B's dependencies for filtering)
- global-maven-proxy (provides access to Maven Central)
Company B has the following repositories:
companyB-maven-group
- companyB-maven-hosted (hosts all of Company B's dependencies they create)
- companyA-maven-hosted (provide read access to Company A's dependencies for filtering)
- global-maven-proxy (the same as the proxy for Company A)
The contents of the hosted repositories are as follows:
companyA-maven-hosted
- com
- companyA
- dep1
- { versions of dep1 }
- dep2
- { version of dep2 }
companyB-maven-hosted
- com
- companyB
- dep3
- { versions of dep3 }
- dep4
- { versions of dep4 }
RBAC
This section will give a general overview of the RBAC content selectors, privileges, and roles created to provide the desired result.
I have created multiple roles for each LDAP group (their is an LDAP group for Company A named company-a
and an LDAP group for Company B named company-b
). These LDAP mappings have the following roles:
companyA-role:
- nx-component-upload
- nx-search-read
- companyA-read-maven
- companyA-write-maven
- companyA-read-maven-companyB
companyA-read-maven:
- nx-repository-view-maven2-companyA-maven-group-read
- nx-repository-view-maven2-companyA-maven-group-browse
companyA-write-maven:
- nx-repository-view-maven2-companyA-maven-hosted-*
companyA-read-maven-companyB:
- read-companyB-public-deps (this is the Content Selector privilege)
There are the same roles created for Company B that mirror the Company A roles swapping instances of companyA
with companyB
(e.g. companyB-read-maven
and companyB-read-maven-companyA
).
The role in question is the companyA-read-maven-companyB
role I created. It has a Content Selector privilege (read-companyB-public-deps
) I created with the following information:
Content Selector: companyB-public-dependencies
Repository: companyB-maven-hosted
Actions: read,browse
The Content Selector companyB-public-dependencies
has the following search expression:
(format == "maven2") and (path =~ "/|/com/|/com/companyB/|/com/companyB/dep3/.*")
Essentially what I’m trying to do with this search expression is provide read and browse access to Company A to the companyB/dep3
dependency (found in companyB-maven-hosted
repository) while preventing read and browse access to the companyB/dep4
dependency.
The Problem
Because companyB-maven-hosted
is part of Company A’s companyA-maven-group
group repository, Company A users see everything from companyB-maven-hosted
. For example, when they use the browser and select the companyA-maven-group
to see the contents, they will see this:
- com
- companyB
- dep3
- { dep3 versions }
- dep4
- { dep4 versions }
I have attempted to change the repository that the companyB-public-dependencies
Content Selector applies to companyA-maven-group
instead of companyB-maven-hosted
, but neither choice works. Regardless of what repository I apply the Content Selector to, Company A users always see all of the contents of the companyB-maven-hosted
repository.
I have been able to get this to work if I remove the companyB-maven-hosted
repository from the companyA-maven-group
group repository, but this requires that Company A now includes the separate repository in their Maven settings.xml
file:
// settings.xml for Company A
...
<repositories>
<repository>
<id>companyA-group</id> // this is created later in the <servers> section
<url>https://my.company.com/repository/companyA-maven-group/</url>
</repository>
<repository>
<id>companyB-hosted</id> // this is created later in the <servers> section
<url>https://my.company.com/repository/companyB-maven-hosted/</url>
</repository>
</repositories>
...
From all that I’ve read, there should be a way to place the companyB-maven-hosted
repository within Company A’s companyA-maven-group
group repository and still apply the Content Selector to filter out any dependencies that should remain private. This would allow the settings.xml
file to only point to a singular repository group and everything should be managed by Nexus. However, I am unaware of how to do this. I have seen articles covering Repository Targets, but my Nexus 3 OSS version doesn’t seem to have that appearing in the admin panel. I have surmised that Content Selectors have replaced the concept of Repository Targets. Any assistance would be much appreciated.
Thank you.