Skip to content

Commit aa4d459

Browse files
authored
feat: Added repo & user password support (#1070)
Signed-off-by: Steve Hipwell <[email protected]>
1 parent 59aeb69 commit aa4d459

10 files changed

+235
-119
lines changed

charts/nexus3/CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414

1515
## [UNRELEASED]
1616

17+
## [v5.3.0] - 2024-10-29
18+
19+
### Added
20+
21+
- Added support for specifying `password.secret` & `password.key` on the `config.repos` objects. ([#1070](https://github.com/stevehipwell/helm-charts/pull/1070)) _@stevehipwell_
22+
- Added support for specifying `password.secret` & `password.key` on the `config.users` objects. ([#1070](https://github.com/stevehipwell/helm-charts/pull/1070)) _@stevehipwell_
23+
24+
### Changed
25+
26+
- Updated ingress docs to better explain hosts. ([#1070](https://github.com/stevehipwell/helm-charts/pull/1070)) _@stevehipwell_
27+
28+
### Deprecated
29+
30+
- Deprecated `.config.repoCredentials` in favour of directly specifying `password.secret` on the `config.repos` objects. ([#1070](https://github.com/stevehipwell/helm-charts/pull/1070)) _@stevehipwell_
31+
1732
## [v5.2.0] - 2024-10-24
1833

1934
> [!IMPORTANT]
@@ -730,6 +745,7 @@ RELEASE LINKS
730745
-->
731746

732747
[UNRELEASED]: https://github.com/stevehipwell/helm-charts/tree/main/charts/nexus3
748+
[v5.3.0]: https://github.com/stevehipwell/helm-charts/releases/tag/nexus3-5.3.0
733749
[v5.2.0]: https://github.com/stevehipwell/helm-charts/releases/tag/nexus3-5.2.0
734750
[v5.1.0]: https://github.com/stevehipwell/helm-charts/releases/tag/nexus3-5.1.0
735751
[v5.0.0]: https://github.com/stevehipwell/helm-charts/releases/tag/nexus3-5.0.0

charts/nexus3/Chart.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: nexus3
33
description: Helm chart for Sonatype Nexus 3 OSS.
44
type: application
5-
version: 5.2.0
5+
version: 5.3.0
66
appVersion: 3.73.0
77
home: https://www.sonatype.com/products/sonatype-nexus-repository
88
icon: https://raw.githubusercontent.com/stevehipwell/helm-charts/main/charts/nexus3/icon.png
@@ -23,11 +23,11 @@ maintainers:
2323
annotations:
2424
artifacthub.io/alternativeName: nexus
2525
artifacthub.io/changes: |
26+
- kind: added
27+
description: "Added support for specifying `password.secret` & `password.key` on the `config.repos` objects."
28+
- kind: added
29+
description: "Added support for specifying `password.secret` & `password.key` on the `config.users` objects."
2630
- kind: changed
27-
description: "Changed the order of the initialization scripts to allow creating roles based on repository privileges."
28-
- kind: changed
29-
description: "Improved docs for config with reference to the API documentation."
30-
- kind: fixed
31-
description: "Fixed LDAP templating incorrectly using `toJson` without passing in the data resulting in no configuration to apply."
32-
- kind: fixed
33-
description: "Fixed incorrect labeling on the volume claim template."
31+
description: "Updated ingress docs to better explain hosts."
32+
- kind: deprecated
33+
description: "Deprecated `.config.repoCredentials` in favour of directly specifying `password.secret` on the `config.repos` objects."

charts/nexus3/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# nexus3
22

3-
![Version: 5.2.0](https://img.shields.io/badge/Version-5.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.73.0](https://img.shields.io/badge/AppVersion-3.73.0-informational?style=flat-square)
3+
![Version: 5.3.0](https://img.shields.io/badge/Version-5.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.73.0](https://img.shields.io/badge/AppVersion-3.73.0-informational?style=flat-square)
44

55
Helm chart for Sonatype Nexus 3 OSS.
66

@@ -25,15 +25,15 @@ Helm chart for Sonatype Nexus 3 OSS.
2525
To install the chart using the recommended OCI method you can use the following command.
2626

2727
```shell
28-
helm upgrade --install nexus3 oci://ghcr.io/stevehipwell/helm-charts/nexus3 --version 5.2.0
28+
helm upgrade --install nexus3 oci://ghcr.io/stevehipwell/helm-charts/nexus3 --version 5.3.0
2929
```
3030

3131
#### Verification
3232

3333
As the OCI chart release is signed by [Cosign](https://github.com/sigstore/cosign) you can verify the chart before installing it by running the following command.
3434

3535
```shell
36-
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com --certificate-identity-regexp 'https://github\.com/action-stars/helm-workflows/\.github/workflows/release\.yaml@.+' --certificate-github-workflow-repository stevehipwell/helm-charts --certificate-github-workflow-name Release ghcr.io/stevehipwell/helm-charts/nexus3:5.2.0
36+
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com --certificate-identity-regexp 'https://github\.com/action-stars/helm-workflows/\.github/workflows/release\.yaml@.+' --certificate-github-workflow-repository stevehipwell/helm-charts --certificate-github-workflow-name Release ghcr.io/stevehipwell/helm-charts/nexus3:5.3.0
3737
```
3838

3939
### Non-OCI Repository
@@ -42,7 +42,7 @@ Alternatively you can use the legacy non-OCI method via the following commands.
4242

4343
```shell
4444
helm repo add stevehipwell https://stevehipwell.github.io/helm-charts/
45-
helm upgrade --install nexus3 stevehipwell/nexus3 --version 5.2.0
45+
helm upgrade --install nexus3 stevehipwell/nexus3 --version 5.3.0
4646
```
4747

4848
## Values
@@ -73,7 +73,7 @@ helm upgrade --install nexus3 stevehipwell/nexus3 --version 5.2.0
7373
| config.ldap | object | `{"authPassword":{"key":null,"secret":null},"authRealm":null,"authScheme":"simple","authUsername":null,"connectionRetryDelaySeconds":300,"connectionTimeoutSeconds":30,"enabled":false,"groupBaseDn":null,"groupIdAttribute":null,"groupMemberAttribute":null,"groupMemberFormat":null,"groupObjectClass":null,"groupSubtree":false,"groupType":"dynamic","host":null,"ldapGroupsAsRoles":false,"maxIncidentsCount":3,"name":null,"port":636,"protocol":"ldaps","searchBase":null,"useTrustStore":true,"userBaseDn":null,"userEmailAddressAttribute":"email","userIdAttribute":"sAMAccountName","userLdapFilter":null,"userMemberOfAttribute":"memberOf","userObjectClass":"user","userPasswordAttribute":null,"userRealNameAttribute":"cn","userSubtree":false}` | LDAP configuration; based on the REST API (API reference docs require an existing Nexus installation and can be found at **Administration** under _System__API_). |
7474
| config.realms.enabled | bool | `false` | If `true`, enable realms. |
7575
| config.realms.values | list | `[]` | List of realms to configure; can be empty or contain any of `NexusAuthenticatingRealm`, `LdapRealm`, `DockerToken`, `NpmToken`, `NuGetApiKey` or `rutauth-realm`. |
76-
| config.repoCredentials.enabled | bool | `false` | If `true`, enable repository credentials. |
76+
| config.repoCredentials.enabled | bool | `false` | **DEPRECATED** - If `true`, enable repository credentials. Use inline repo password instead. |
7777
| config.repoCredentials.secret | string | `nil` | Name of the secret containing the repository credentials. |
7878
| config.repos | list | `[]` | Repository configuration; based on the REST API (API reference docs require an existing Nexus installation and can be found at **Administration** under _System__API_) but with `format` & `type` defined in the object. |
7979
| config.roles | list | `[]` | Roles configuration; based on the REST API (API reference docs require an existing Nexus installation and can be found at **Administration** under _System__API_). |
@@ -91,9 +91,9 @@ helm upgrade --install nexus3 stevehipwell/nexus3 --version 5.2.0
9191
| imagePullSecrets | list | `[]` | Image pull secrets. |
9292
| ingress.annotations | object | `{}` | Ingress annotations. |
9393
| ingress.enabled | bool | `false` | If `true`, create an `Ingress` resource. |
94-
| ingress.hosts | list | See _values.yaml_ | Ingress hosts. |
94+
| ingress.hosts | list | See _values.yaml_ | Ingress hosts, do not include hosts defined in `service.additionalPorts`. |
9595
| ingress.ingressClassName | string | `nil` | Ingress class name. |
96-
| ingress.tls | list | See _values.yaml_ | Ingress TLS. |
96+
| ingress.tls | list | See _values.yaml_ | Ingress TLS, hosts defined in both `ingress.hosts` & `service.additionalPorts[*].hosts` should be covered. |
9797
| install4jAddVmParams | string | `"-Xms1024m -Xmx1024m -XX:MaxDirectMemorySize=2048m"` | Env configuration for the _Nexus3_ container. |
9898
| jdkImage.digest | string | `nil` | Optional image digest for the JDK container. |
9999
| jdkImage.pullPolicy | string | `"IfNotPresent"` | Image pull policy for the JDK container. |

charts/nexus3/ci/ci-values.yaml

+34-20
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,6 @@ config:
3333
- NpmToken
3434
- NuGetApiKey
3535
- rutauth-realm
36-
roles:
37-
- id: nexus-administrators
38-
source: default
39-
name: nexus-administrators
40-
description: LDAP Administrator Role
41-
privileges: []
42-
roles:
43-
- nx-admin
44-
users:
45-
- userId: test
46-
firstName: Test
47-
lastName: User
48-
emailAddress: [email protected]
49-
source: default
50-
status: active
51-
roles:
52-
- nx-anonymous
53-
externalRoles: []
54-
ldap:
55-
enabled: false
5636
blobStores: []
5737
cleanup:
5838
- name: ExampleCleanup
@@ -78,6 +58,40 @@ config:
7858
cleanup:
7959
policyNames:
8060
- ExampleCleanup
61+
roles:
62+
- id: nexus-administrators
63+
source: default
64+
name: nexus-administrators
65+
description: LDAP Administrator Role
66+
privileges: []
67+
roles:
68+
- nx-admin
69+
users:
70+
- userId: test
71+
firstName: Test
72+
lastName: User
73+
emailAddress: [email protected]
74+
source: default
75+
status: active
76+
roles:
77+
- nx-anonymous
78+
externalRoles: []
79+
password:
80+
secret: test-user
81+
key: passwordx
82+
- userId: test2
83+
firstName: Test2
84+
lastName: User
85+
emailAddress: [email protected]
86+
source: default
87+
status: active
88+
roles:
89+
- nx-anonymous
90+
externalRoles: []
91+
password:
92+
secret: test-user2
93+
ldap:
94+
enabled: false
8195
tasks:
8296
- name: "Cleanup service"
8397
typeId: repository.cleanup

charts/nexus3/ci/kubeconform.yaml

+37-20
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,6 @@ config:
127127
- NpmToken
128128
- NuGetApiKey
129129
- rutauth-realm
130-
roles:
131-
- id: nexus-administrators
132-
source: default
133-
name: nexus-administrators
134-
description: LDAP Administrator Role
135-
privileges: []
136-
roles:
137-
- nx-admin
138-
users:
139-
- userId: test
140-
firstName: Test
141-
lastName: User
142-
emailAddress: [email protected]
143-
source: default
144-
status: active
145-
roles:
146-
- nx-anonymous
147-
externalRoles: []
148-
ldap:
149-
enabled: false
150130
blobStores:
151131
- name: ExampleFileBlobStore
152132
type: file
@@ -179,6 +159,43 @@ config:
179159
cleanup:
180160
policyNames:
181161
- ExampleCleanup
162+
password:
163+
secret: test-repo
164+
key: passwordx
165+
roles:
166+
- id: nexus-administrators
167+
source: default
168+
name: nexus-administrators
169+
description: LDAP Administrator Role
170+
privileges: []
171+
roles:
172+
- nx-admin
173+
users:
174+
- userId: test
175+
firstName: Test
176+
lastName: User
177+
emailAddress: [email protected]
178+
source: default
179+
status: active
180+
roles:
181+
- nx-anonymous
182+
externalRoles: []
183+
password:
184+
secret: test-user
185+
key: passwordx
186+
- userId: test2
187+
firstName: Test2
188+
lastName: User
189+
emailAddress: [email protected]
190+
source: default
191+
status: active
192+
roles:
193+
- nx-anonymous
194+
externalRoles: []
195+
password:
196+
secret: test-user2
197+
ldap:
198+
enabled: false
182199
tasks:
183200
- name: "Cleanup service"
184201
typeId: repository.cleanup

charts/nexus3/scripts/configure.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ for json_file in "${CONFIG_DIR}"/conf/*-repo.json; do
128128
json_file="${tmp_file}"
129129

130130
if [[ "${type}" == "proxy" ]]; then
131-
password_file="${CONFIG_DIR}/secret/repo-credentials/${name}"
131+
password_file="${CONFIG_DIR}/secret/repo-${name}.password"
132+
if [[ ! -f "${password_file}" ]]; then
133+
password_file="${CONFIG_DIR}/secret/repo-credentials/${name}"
134+
fi
132135
if [[ -f "${password_file}" ]]; then
133136
tmp_file="$(mktemp -p "${tmp_dir}")"
134137
jq -r --arg password "$(cat "${password_file}")" '. * {httpClient: {authentication: {password: $password}}}' "${json_file}" >"${tmp_file}"
@@ -190,8 +193,13 @@ for json_file in "${CONFIG_DIR}"/conf/*-user.json; do
190193
error "Could not update user '${id}'."
191194
fi
192195
else
196+
password_file="${CONFIG_DIR}/secret/user-${id}.password"
197+
if [[ ! -f "${password_file}" ]]; then
198+
echo "${RANDOM}" | md5sum | head -c 20 >"${password_file}"
199+
fi
200+
193201
tmp_file="$(mktemp -p "${tmp_dir}")"
194-
jq -r --arg password "$(echo "${RANDOM}" | md5sum | head -c 20)" '. + {password: $password}' "${json_file}" >"${tmp_file}"
202+
jq -r --arg password "$(cat "${password_file}")" '. + {password: $password}' "${json_file}" >"${tmp_file}"
195203
json_file="${tmp_file}"
196204

197205
status_code="$(curl -sS -o /dev/null -w "%{http_code}" -X POST -H 'Content-Type: application/json' -u "${NEXUS_USER}:${password}" -d "@${json_file}" "${NEXUS_HOST}/service/rest/v1/security/users")"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{{- if .Values.testResources -}}
2+
{{- range concat .Values.config.repos .Values.config.users }}
3+
{{- if dig "password" "secret" nil . }}
4+
{{- $secretName := .password.secret -}}
5+
{{- $key := default "password" .password.key }}
6+
{{- $secret := lookup "v1" "Secret" $.Release.Namespace $secretName -}}
7+
{{- $password := (randAlpha 16) | b64enc }}
8+
{{- if $secret }}
9+
{{- $password = index $secret.data $key -}}
10+
{{- end }}
11+
apiVersion: v1
12+
kind: Secret
13+
metadata:
14+
name: {{ $secretName }}
15+
namespace: {{ $.Release.Namespace }}
16+
labels:
17+
{{- include "nexus3.labels" $ | nindent 4 }}
18+
test-resource: "true"
19+
annotations:
20+
"helm.sh/hook": "pre-install"
21+
type: Opaque
22+
data:
23+
{{ $key }}: {{ $password | quote }}
24+
---
25+
{{- end }}
26+
{{- end }}
27+
{{- end }}

charts/nexus3/templates/configmap-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data:
2525
{{- end }}
2626
{{- range .Values.config.users }}
2727
{{ .userId }}-user.json: |
28-
{{- . | toJson | nindent 4 }}
28+
{{- omit . "password" | toJson | nindent 4 }}
2929
{{- end }}
3030
{{- if .Values.config.ldap.enabled }}
3131
ldap.json: |
@@ -43,7 +43,7 @@ data:
4343
{{- end }}
4444
{{- range $index, $repo := .Values.config.repos }}
4545
{{ $index | add 1000 | toString | substr 1 -1 }}-repo.json: |
46-
{{- $repo | toJson | nindent 4 }}
46+
{{- omit $repo "password" | toJson | nindent 4 }}
4747
{{- end }}
4848
{{- range $index, $task := .Values.config.tasks }}
4949
{{ $index | add 1000 | toString | substr 1 -1 }}-task.json: |

charts/nexus3/templates/job-config.yaml

+37-9
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,29 @@ spec:
5151
name: scripts
5252
- mountPath: /opt/sonatype/nexus/config/conf
5353
name: config
54+
{{- if .Values.config.repoCredentials.enabled }}
55+
- mountPath: /opt/sonatype/nexus/config/secret/repo-credentials
56+
name: repo-credentials
57+
{{- end }}
58+
{{- range .Values.config.repos }}
59+
{{- if dig "password" "secret" nil . }}
60+
- mountPath: {{ printf "/opt/sonatype/nexus/config/secret/repo-%s.password" .name }}
61+
name: {{ printf "repo-%s" .name }}
62+
subPath: {{ default "password" .password.key }}
63+
{{- end }}
64+
{{- end }}
65+
{{- range .Values.config.users }}
66+
{{- if dig "password" "secret" nil . }}
67+
- mountPath: {{ printf "/opt/sonatype/nexus/config/secret/user-%s.password" .userId }}
68+
name: {{ printf "user-%s" .userId }}
69+
subPath: {{ default "password" .password.key }}
70+
{{- end }}
71+
{{- end }}
5472
{{- if .Values.config.ldap.enabled }}
5573
- mountPath: /opt/sonatype/nexus/config/secret/ldap.password
5674
name: ldap-password
5775
subPath: {{ .Values.config.ldap.authPassword.key }}
5876
{{- end }}
59-
{{- if .Values.config.repoCredentials.enabled }}
60-
- mountPath: /opt/sonatype/nexus/config/secret/repo-credentials
61-
name: repo-credentials
62-
{{- end }}
6377
volumes:
6478
- name: temp
6579
emptyDir: {}
@@ -71,16 +85,30 @@ spec:
7185
configMap:
7286
name: {{ include "nexus3.configConfigMapName" . }}
7387
defaultMode: 0444
74-
{{- if .Values.config.ldap.enabled }}
75-
- name: ldap-password
76-
secret:
77-
secretName: {{ .Values.config.ldap.authPassword.secret }}
78-
{{- end }}
7988
{{- if .Values.config.repoCredentials.enabled }}
8089
- name: repo-credentials
8190
secret:
8291
secretName: {{ .Values.config.repoCredentials.secret }}
8392
{{- end }}
93+
{{- range .Values.config.repos }}
94+
{{- if dig "password" "secret" nil . }}
95+
- name: {{ printf "repo-%s" .name }}
96+
secret:
97+
secretName: {{ .password.secret }}
98+
{{- end }}
99+
{{- end }}
100+
{{- range .Values.config.users }}
101+
{{- if dig "password" "secret" nil . }}
102+
- name: {{ printf "user-%s" .userId }}
103+
secret:
104+
secretName: {{ .password.secret }}
105+
{{- end }}
106+
{{- end }}
107+
{{- if .Values.config.ldap.enabled }}
108+
- name: ldap-password
109+
secret:
110+
secretName: {{ .Values.config.ldap.authPassword.secret }}
111+
{{- end }}
84112
{{- with .Values.config.job.nodeSelector }}
85113
nodeSelector:
86114
{{- toYaml . | nindent 8 }}

0 commit comments

Comments
 (0)