Skip to content

Commit

Permalink
Merge pull request #172 from Nabsku/develop
Browse files Browse the repository at this point in the history
Changed Templates to use the new remoteAuth.backends array, instead of .backend
  • Loading branch information
RangerRick committed May 8, 2024
2 parents acc811e + 72b1315 commit bf14c17
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 33 deletions.
2 changes: 1 addition & 1 deletion charts/netbox/Chart.yaml
@@ -1,6 +1,6 @@
apiVersion: v2
name: netbox
version: 5.0.0-beta7
version: 5.0.0-beta8
appVersion: "v4.0.0"
type: application
kubeVersion: ^1.25.0-0
Expand Down
44 changes: 23 additions & 21 deletions charts/netbox/templates/configmap.yaml
Expand Up @@ -224,7 +224,8 @@ data:
DATETIME_FORMAT: {{ .Values.dateTimeFormat | quote }}
SHORT_DATETIME_FORMAT: {{ .Values.shortDateTimeFormat | quote }}
{{- if eq .Values.remoteAuth.backend "netbox.authentication.LDAPBackend" }}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}

ldap_config.py: |-
from importlib import import_module
Expand Down Expand Up @@ -276,32 +277,33 @@ data:
# Define special user types using groups. Exercise great caution when assigning superuser status.
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_active": AUTH_LDAP_REQUIRE_GROUP,
"is_staff": {{ .Values.remoteAuth.ldap.isAdminDn | quote }},
"is_superuser": {{ .Values.remoteAuth.ldap.isSuperUserDn | quote }},
"is_staff": {{ $.Values.remoteAuth.ldap.isAdminDn | quote }},
"is_superuser": {{ $.Values.remoteAuth.ldap.isSuperUserDn | quote }},
}
# Populate the Django user from the LDAP directory.
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": {{ .Values.remoteAuth.ldap.attrFirstName | quote }},
"last_name": {{ .Values.remoteAuth.ldap.attrLastName | quote }},
"email": {{ .Values.remoteAuth.ldap.attrMail | quote }},
"first_name": {{ $.Values.remoteAuth.ldap.attrFirstName | quote }},
"last_name": {{ $.Values.remoteAuth.ldap.attrLastName | quote }},
"email": {{ $.Values.remoteAuth.ldap.attrMail | quote }},
}
ldap.yaml: |-
AUTH_LDAP_SERVER_URI: {{ .Values.remoteAuth.ldap.serverUri | quote }}
AUTH_LDAP_BIND_DN: {{ .Values.remoteAuth.ldap.bindDn | quote }}
AUTH_LDAP_START_TLS: {{ toJson .Values.remoteAuth.ldap.startTls }}
LDAP_IGNORE_CERT_ERRORS: {{ toJson .Values.remoteAuth.ldap.ignoreCertErrors }}
AUTH_LDAP_USER_DN_TEMPLATE: {{ default nil .Values.remoteAuth.ldap.userDnTemplate }}
AUTH_LDAP_USER_SEARCH_BASEDN: {{ .Values.remoteAuth.ldap.userSearchBaseDn | quote }}
AUTH_LDAP_USER_SEARCH_ATTR: {{ .Values.remoteAuth.ldap.userSearchAttr | quote }}
AUTH_LDAP_GROUP_SEARCH_BASEDN: {{ .Values.remoteAuth.ldap.groupSearchBaseDn | quote }}
AUTH_LDAP_GROUP_SEARCH_CLASS: {{ .Values.remoteAuth.ldap.groupSearchClass | quote }}
AUTH_LDAP_GROUP_TYPE: {{ .Values.remoteAuth.ldap.groupType | quote }}
AUTH_LDAP_REQUIRE_GROUP: {{ .Values.remoteAuth.ldap.requireGroupDn | quote }}
AUTH_LDAP_FIND_GROUP_PERMS: {{ toJson .Values.remoteAuth.ldap.findGroupPerms }}
AUTH_LDAP_MIRROR_GROUPS: {{ toJson .Values.remoteAuth.ldap.mirrorGroups }}
AUTH_LDAP_MIRROR_GROUPS_EXCEPT: {{ toJson .Values.remoteAuth.ldap.mirrorGroupsExcept }}
AUTH_LDAP_CACHE_TIMEOUT: {{ int .Values.remoteAuth.ldap.cacheTimeout }}
AUTH_LDAP_SERVER_URI: {{ $.Values.remoteAuth.ldap.serverUri | quote }}
AUTH_LDAP_BIND_DN: {{ $.Values.remoteAuth.ldap.bindDn | quote }}
AUTH_LDAP_START_TLS: {{ toJson $.Values.remoteAuth.ldap.startTls }}
LDAP_IGNORE_CERT_ERRORS: {{ toJson $.Values.remoteAuth.ldap.ignoreCertErrors }}
AUTH_LDAP_USER_DN_TEMPLATE: {{ default nil $.Values.remoteAuth.ldap.userDnTemplate }}
AUTH_LDAP_USER_SEARCH_BASEDN: {{ $.Values.remoteAuth.ldap.userSearchBaseDn | quote }}
AUTH_LDAP_USER_SEARCH_ATTR: {{ $.Values.remoteAuth.ldap.userSearchAttr | quote }}
AUTH_LDAP_GROUP_SEARCH_BASEDN: {{ $.Values.remoteAuth.ldap.groupSearchBaseDn | quote }}
AUTH_LDAP_GROUP_SEARCH_CLASS: {{ $.Values.remoteAuth.ldap.groupSearchClass | quote }}
AUTH_LDAP_GROUP_TYPE: {{ $.Values.remoteAuth.ldap.groupType | quote }}
AUTH_LDAP_REQUIRE_GROUP: {{ $.Values.remoteAuth.ldap.requireGroupDn | quote }}
AUTH_LDAP_FIND_GROUP_PERMS: {{ toJson $.Values.remoteAuth.ldap.findGroupPerms }}
AUTH_LDAP_MIRROR_GROUPS: {{ toJson $.Values.remoteAuth.ldap.mirrorGroups }}
AUTH_LDAP_MIRROR_GROUPS_EXCEPT: {{ toJson $.Values.remoteAuth.ldap.mirrorGroupsExcept }}
AUTH_LDAP_CACHE_TIMEOUT: {{ int $.Values.remoteAuth.ldap.cacheTimeout }}
{{- end }}
{{- end }}
{{- if .Values.overrideUnitConfig }}

Expand Down
10 changes: 7 additions & 3 deletions charts/netbox/templates/cronjob.yaml
Expand Up @@ -61,12 +61,14 @@ spec:
mountPath: /etc/netbox/config/configuration.py
subPath: configuration.py
readOnly: true
{{ if eq .Values.remoteAuth.backend "netbox.authentication.LDAPBackend" -}}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_config.py
subPath: ldap_config.py
readOnly: true
{{ end -}}
{{- end }}
{{- end }}
- name: config
mountPath: /run/config/netbox
readOnly: true
Expand Down Expand Up @@ -110,10 +112,12 @@ spec:
path: email_password
- key: secret_key
path: secret_key
{{- if eq .Values.remoteAuth.backend "netbox.authentication.LDAPBackend" }}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
{{- end }}
- secret:
name: {{ include "netbox.postgresql.secret" . | quote }}
items:
Expand Down
10 changes: 7 additions & 3 deletions charts/netbox/templates/deployment.yaml
Expand Up @@ -116,12 +116,14 @@ spec:
mountPath: /etc/netbox/config/configuration.py
subPath: configuration.py
readOnly: true
{{ if eq .Values.remoteAuth.backend "netbox.authentication.LDAPBackend" -}}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_config.py
subPath: ldap_config.py
readOnly: true
{{ end -}}
{{- end }}
{{- end }}
- name: config
mountPath: /run/config/netbox
readOnly: true
Expand Down Expand Up @@ -180,10 +182,12 @@ spec:
path: email_password
- key: secret_key
path: secret_key
{{- if eq .Values.remoteAuth.backend "netbox.authentication.LDAPBackend" }}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
{{- end }}
- secret:
name: {{ include "netbox.postgresql.secret" . | quote }}
items:
Expand Down
6 changes: 4 additions & 2 deletions charts/netbox/templates/secret.yaml
Expand Up @@ -23,7 +23,9 @@ data:
secret_key: {{ .Values.secretKey | default (randAscii 60) | b64enc }}
superuser_password: {{ .Values.superuser.password | default (randAlphaNum 16) | b64enc }}
superuser_api_token: {{ .Values.superuser.apiToken | default uuidv4 | b64enc }}
{{ if eq .Values.remoteAuth.backend "netbox.authentication.LDAPBackend" -}}
ldap_bind_password: {{ .Values.remoteAuth.ldap.bindPassword | b64enc | quote }}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
ldap_bind_password: {{ $.Values.remoteAuth.ldap.bindPassword | b64enc | quote }}
{{ end -}}
{{ end -}}
{{- end -}}
10 changes: 7 additions & 3 deletions charts/netbox/templates/worker-deployment.yaml
Expand Up @@ -69,12 +69,14 @@ spec:
mountPath: /etc/netbox/config/configuration.py
subPath: configuration.py
readOnly: true
{{ if eq .Values.remoteAuth.backend "netbox.authentication.LDAPBackend" -}}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_config.py
subPath: ldap_config.py
readOnly: true
{{ end -}}
{{- end }}
{{- end }}
- name: config
mountPath: /run/config/netbox
readOnly: true
Expand Down Expand Up @@ -118,10 +120,12 @@ spec:
path: email_password
- key: secret_key
path: secret_key
{{- if eq .Values.remoteAuth.backend "netbox.authentication.LDAPBackend" }}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
{{- end }}
- secret:
name: {{ include "netbox.postgresql.secret" . | quote }}
items:
Expand Down

0 comments on commit bf14c17

Please sign in to comment.