Skip to content

Commit 5b19516

Browse files
committed
fix:[nmrxiv-app]update chart to fix CSRF issue
1 parent fc9cd5b commit 5b19516

File tree

4 files changed

+79
-12
lines changed

4 files changed

+79
-12
lines changed

charts/nmrxiv-app/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ maintainers:
66
77

88
type: application
9-
version: 1.0.3
9+
version: 1.2.0
1010
appVersion: "1.16.0"
1111

1212
dependencies:

charts/nmrxiv-app/templates/configmap.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,25 @@ data:
5656
MEMCACHED_HOST: {{ .Values.redis.memcachedHost | quote }}
5757
REDIS_HOST: {{ printf "%s-redis-master" .Release.Name | quote }}
5858
REDIS_PORT: {{ .Values.redis.port | default 6379 | quote }}
59+
{{ else }}
60+
SESSION_DRIVER: {{ .Values.sessionDriver | default "database" | quote }}
61+
SESSION_LIFETIME: "{{ .Values.sessionLifetime | default 120 }}"
5962
{{ end }}
6063

64+
#Session Security Properties
65+
SESSION_SECURE_COOKIE: "{{ .Values.session.secureCookie | default true }}"
66+
SESSION_SAME_SITE: {{ .Values.session.sameSite | default "lax" | quote }}
67+
SESSION_COOKIE: {{ .Values.session.cookieName | default "nmrxiv_session" | quote }}
68+
69+
#Trusted Proxies for CSRF Protection
70+
TRUSTED_PROXIES: {{ .Values.trustedProxies | default "*" | quote }}
71+
72+
#CSRF Configuration
73+
SANCTUM_STATEFUL_DOMAINS: {{ .Values.sanctum.statefulDomains | default .Values.appProperties.url | quote }}
74+
75+
#Force HTTPS for URL generation (important in Kubernetes with ingress)
76+
FORCE_HTTPS: "{{ .Values.forceHttps | default true }}"
77+
6178
#RabbitMQ Properties
6279
{{ if .Values.rabbitmq.enabled }}
6380
QUEUE_CONNECTION: {{ .Values.rabbitmq.queueConnection | quote }}
Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
11
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "nmrxiv-app.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
24
apiVersion: networking.k8s.io/v1
35
kind: Ingress
46
metadata:
5-
name: {{ include "nmrxiv-app.fullname" . }}-ingress
7+
name: {{ $fullName }}
8+
labels:
9+
{{- include "nmrxiv-app.labels" . | nindent 4 }}
10+
{{- with .Values.ingress.annotations }}
611
annotations:
7-
{{- toYaml .Values.ingress.annotations | nindent 4 }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
814
spec:
9-
defaultBackend:
10-
service:
11-
name: {{ include "nmrxiv-app.fullname" . }}
12-
port:
13-
number: {{ .Values.service.port }}
15+
{{- if .Values.ingress.className }}
16+
ingressClassName: {{ .Values.ingress.className }}
17+
{{- end }}
18+
{{- if .Values.ingress.tls }}
19+
tls:
20+
{{- range .Values.ingress.tls }}
21+
- hosts:
22+
{{- range .hosts }}
23+
- {{ . | quote }}
24+
{{- end }}
25+
secretName: {{ .secretName }}
26+
{{- end }}
27+
{{- end }}
28+
rules:
29+
{{- range .Values.ingress.hosts }}
30+
- host: {{ .host | quote }}
31+
http:
32+
paths:
33+
{{- range .paths }}
34+
- path: {{ .path }}
35+
pathType: {{ .pathType }}
36+
backend:
37+
service:
38+
name: {{ $fullName }}
39+
port:
40+
number: {{ $svcPort }}
41+
{{- end }}
42+
{{- end }}
1443
{{- end }}

charts/nmrxiv-app/values.yaml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ service:
101101
ingress:
102102
enabled: false
103103
className: ""
104-
annotations: {
105-
# kubernetes.io/ingress.global-static-ip-name: nmrxiv-app-ip-address
106-
# kubernetes.io/ingress.class: "nginx"
107-
}
104+
annotations:
105+
# Essential for Laravel CSRF protection behind ingress
106+
nginx.ingress.kubernetes.io/configuration-snippet: |
107+
more_set_headers "X-Forwarded-Proto: https";
108+
more_set_headers "X-Forwarded-Port: 443";
108109
hosts:
109110
- host: chart-example.local
110111
paths:
@@ -242,6 +243,26 @@ redis:
242243
sessionLifetime: 120
243244
memcachedHost: memcached
244245

246+
# Session configuration for Laravel when Redis is disabled
247+
sessionDriver: database
248+
sessionLifetime: 120
249+
250+
# Session security settings (critical for HTTPS deployments)
251+
session:
252+
secureCookie: true
253+
sameSite: lax
254+
cookieName: nmrxiv_session
255+
256+
# Trusted proxies configuration (required for proper CSRF handling behind ingress/load balancer)
257+
trustedProxies: "*"
258+
259+
# Sanctum configuration for API authentication
260+
sanctum:
261+
statefulDomains: "" # Will default to APP_URL if not set
262+
263+
# Force HTTPS URLs (important for Kubernetes deployments with HTTPS ingress)
264+
forceHttps: true
265+
245266
rabbitmq:
246267
enabled: false
247268
queueConnection: sync

0 commit comments

Comments
 (0)