Skip to content

Commit a1a187d

Browse files
Clément VALENTINclaude
andcommitted
fix: corriger la détection admin (combiner DB + ADMIN_EMAILS)
- is_admin utilise maintenant user.is_admin OR settings.is_admin(email) - Ajouter authentification Redis dans Helm (existingSecret) - REDIS_PASSWORD injecté depuis le secret externe 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 84c2a37 commit a1a187d

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

apps/api/src/routers/accounts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ async def get_current_user_info(
271271
)
272272

273273
# Add is_admin field, debug_mode, and role
274+
# is_admin is true if: database flag OR email in ADMIN_EMAILS env var
274275
user_data = user_response.model_dump()
275-
user_data['is_admin'] = settings.is_admin(user.email)
276+
user_data['is_admin'] = user.is_admin or settings.is_admin(user.email)
276277
user_data['debug_mode'] = user.debug_mode
277278

278279
# Add role information with permissions

helm/myelectricaldata/templates/_helpers.tpl

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,44 @@ postgresql+asyncpg://{{ $username }}:$(POSTGRES_PASSWORD)@{{ $host }}:{{ $port }
191191
{{- end }}
192192

193193
{{/*
194-
Redis URL
194+
Redis secret name - Supports external secrets or subchart-generated secrets
195+
*/}}
196+
{{- define "myelectricaldata.redis.secretName" -}}
197+
{{- if .Values.redis.enabled }}
198+
{{- if .Values.redis.auth.existingSecret }}
199+
{{- .Values.redis.auth.existingSecret }}
200+
{{- else }}
201+
{{- printf "%s-redis" .Release.Name }}
202+
{{- end }}
203+
{{- else if .Values.externalRedis.existingSecret }}
204+
{{- .Values.externalRedis.existingSecret }}
205+
{{- else }}
206+
{{- printf "%s-external-redis" (include "myelectricaldata.fullname" .) }}
207+
{{- end }}
208+
{{- end }}
209+
210+
{{/*
211+
Redis secret key - Returns the key name for the password in the secret
212+
*/}}
213+
{{- define "myelectricaldata.redis.secretKey" -}}
214+
{{- if .Values.redis.enabled }}
215+
{{- if .Values.redis.auth.existingSecret }}
216+
{{- .Values.redis.auth.existingSecretKey | default "redis-password" }}
217+
{{- else }}
218+
{{- "redis-password" }}
219+
{{- end }}
220+
{{- else }}
221+
{{- "password" }}
222+
{{- end }}
223+
{{- end }}
224+
225+
{{/*
226+
Redis URL - uses REDIS_PASSWORD env var for the password
195227
*/}}
196228
{{- define "myelectricaldata.redisUrl" -}}
197229
{{- $host := include "myelectricaldata.redis.host" . -}}
198230
{{- $port := include "myelectricaldata.redis.port" . -}}
199-
redis://{{ $host }}:{{ $port }}/0
231+
redis://:$(REDIS_PASSWORD)@{{ $host }}:{{ $port }}/0
200232
{{- end }}
201233

202234
{{/*

helm/myelectricaldata/templates/backend/backend-deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ spec:
6767
key: {{ include "myelectricaldata.postgres.secretKey" . | trim }}
6868
- name: DATABASE_URL
6969
value: {{ include "myelectricaldata.databaseUrl" . | quote }}
70+
# Redis password MUST be defined before REDIS_URL for $(REDIS_PASSWORD) substitution
71+
- name: REDIS_PASSWORD
72+
valueFrom:
73+
secretKeyRef:
74+
name: {{ include "myelectricaldata.redis.secretName" . | trim }}
75+
key: {{ include "myelectricaldata.redis.secretKey" . | trim }}
7076
- name: REDIS_URL
7177
value: {{ include "myelectricaldata.redisUrl" . | quote }}
7278
- name: ENEDIS_ENVIRONMENT

helm/myelectricaldata/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,15 @@ redis:
250250
tag: "7-alpine"
251251
pullPolicy: IfNotPresent
252252

253+
# Redis authentication
254+
auth:
255+
# Option 1: Set password directly (Helm creates the secret)
256+
password: ""
257+
# Option 2: Use an existing secret with a generated password
258+
# The secret must contain the key specified in existingSecretKey
259+
existingSecret: "" # e.g., "redis-credentials"
260+
existingSecretKey: "redis-password" # Key containing the password in the secret
261+
253262
# Redis configuration
254263
config:
255264
maxmemory: "256mb"

0 commit comments

Comments
 (0)