Using Content Selectors to Filter Browse View

I am trying to setup content selectors to filter the “browseable” view. I have followed these steps from SO (nexus3 - Nexus 3 and Content Selectors - Stack Overflow) but when I log in as the user the browse view is completely empty. Search-Read appears to work fine though.

I am not using the anonymous user and have created a different user with the permissions, privileges, roles, etc. The content selector itself looks to work when I preview it.

I’m guessing that your content selectors need to be modified to allow browsing of directory listings.

This article was written for Nexus Repo 2, but since Repo 3 also uses path based privileges the principles apply for it also:

Makes sense but I am confused where I should apply that.

This is what my content selector looks like now:

(path =^ “.*/”) and
(format==“maven2” and coordinate.groupId=^ “my.package”) or
(format==“npm” and path =^ “@my/package”) or
(format==“nuget” and path =^ “My.Package”) or
(format==“pypi” and path =^ “packages/my-package”)

Should I be applying this in the content selector or is this a different privilege (wildcard)? The above does not work for me if it is correct.

You’ll need to use this:

(path =~ “.*/”) and

Instead of this:

(path =^ “.*/”) and

The first one does a regular expression match, the second one does a “starts with” match.

For the other ones, you’ll want to change them to use regular expressions with path based matching, and also start the paths with “/”, as in:

format==“maven2” and path=~ “/my/package/.*”

Also note that there is a problem with pypi… it uses POST requests for component uploads.

This means that it will not be possible to restrict pypi deployments using content selectors as they currently exist, since there is no path for them to work against.

We have an issue in our backlog to address this, but it has not yet been scheduled:

1 Like

Thanks so much for the help. It seems to be getting closer…I could only get the results back when I switched or’d the first regex.

(path =~ “./") or
(format==“maven2” and path =~ "^/my/package.
”) or
(format==“npm” and path =~ “^/@my/package.") or
(format==“nuget” and path =~ "^/My.Package.
”) or
(format==“pypi” and path =~ “^/packages/my-package.*”)

Will return the whole view of the repository but only what is specified in the selector can be accessed it seems. Functionally, this works for me.

I am apply this selector against my “public” (grouped repositories). I was under the impression is would provide a filtered view of that repository? and not the whole thing with limited access?

I am apply this selector against my “public” (grouped repositories). I was under the impression is would provide a filtered view of that repository? and not the whole thing with limited access?

This gives access to all directory listings, so everything will be visible:

(path =~ “./")

You’d need something like this to restrict viewing to a specific path:

 /|/com/|/com/mycompany/|/com/mycompany/team-a/.* 
1 Like