Skip to content

Commit bfa713d

Browse files
author
lijie
committed
refract: remove fixed jwt token
1 parent 5246254 commit bfa713d

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

release/cluster/helm/templates/config-polaris-console.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ data:
1616
listenIP: "0.0.0.0"
1717
listenPort: {{ .Values.service.webPort }}
1818
jwt:
19-
secretKey: "polarismesh@2021"
19+
secretKey: "${JWT_KEY}"
2020
expired: 1800
2121
namingV1URL: "/naming/v1"
2222
namingV2URL: "/naming/v2"

release/cluster/helm/templates/polaris-server.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ spec:
8686
- mountPath: /root/polaris-console.yaml
8787
name: polaris-console-config
8888
subPath: polaris-console.yaml
89+
env:
90+
- name: JWT_KEY
91+
valueFrom:
92+
secretKeyRef:
93+
name: {{ .Release.Name }}
94+
key: JWT_KEY
8995
restartPolicy: Always
9096
volumes:
9197
- configMap:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ .Release.Name }}
5+
type: Opaque
6+
data:
7+
{{- $existingSecret := lookup "v1" "Secret" .Release.Namespace .Release.Name }}
8+
{{- if $existingSecret }}
9+
# 复用已存在的值
10+
JWT_KEY: {{ index $existingSecret.data "JWT_KEY" }}
11+
{{- else }}
12+
# 生成新随机值
13+
JWT_KEY: {{ randAlphaNum 16 | b64enc | quote }}
14+
{{- end }}

0 commit comments

Comments
 (0)