How to only grant access to specific tags and specified namespaces in Sonatype Nexus3?
As an example, we will use an image with the name: docker.domain.com/namespace/image:1.1.1
We only want to allow the user to pull images that have a tag that matches our Semver regex. (you can simply adjust the regex to your own needs)
format == 'docker'
&& (
path == '/v2/'
|| (
path =~ '.*/namespace/.*'
&& (
path =~ '.*[0-9]+\.[0-9]+\.[0-9]+'
|| path =~ '.*/blobs/.*'
)
)
)
&&
AND operator||
OR operator==
EQUAL operator=~
REGEX operatorformat == 'docker'
sets the format type that should be selectedpath == '/v2/'
grants login and manifest privileges as explained docker v2 API specificationpath=~'.*/blobs/.*'
grants pull access to the image layerspath=~'.*[0-9]+\.[0-9]+\.[0-9]+'
Semver-regexThe most important part is the combination of the namespace and Semver-regex, namespace and blobs path.
Edit: Please see rseddons answer here for a deeper explanation.