Skip to content

Commit f6ba618

Browse files
authored
Merge pull request #15 from jianxiaoguo/dev
chore(oauth): login with passport oauth2
2 parents 5324aa0 + 5cd2ee5 commit f6ba618

3 files changed

Lines changed: 83 additions & 38 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{/* Generate monitor grafana envs */}}
2+
{{- define "grafana.envs" }}
3+
env:
4+
{{- if eq .Values.global.influxdb_location "off-cluster" }}
5+
- name: "INFLUXDB_URL"
6+
valueFrom:
7+
secretKeyRef:
8+
name: influxdb-creds
9+
key: url
10+
{{- else }}
11+
- name: "INFLUXDB_URL"
12+
value: http://$(DRYCC_INFLUXDB_SERVICE_HOST):$(DRYCC_INFLUXDB_SERVICE_PORT_TRANSPORT)
13+
{{- end }}
14+
- name: "INFLUXDB_BUCKET"
15+
valueFrom:
16+
secretKeyRef:
17+
name: influxdb-creds
18+
key: bucket
19+
- name: "INFLUXDB_ORG"
20+
valueFrom:
21+
secretKeyRef:
22+
name: influxdb-creds
23+
key: org
24+
- name: "INFLUXDB_TOKEN"
25+
valueFrom:
26+
secretKeyRef:
27+
name: influxdb-creds
28+
key: token
29+
- name: "BIND_PORT"
30+
value: "3000"
31+
- name: "DEFAULT_USER"
32+
value: {{.Values.grafana.user}}
33+
- name: "DEFAULT_USER_PASSWORD"
34+
value: {{.Values.grafana.password}}
35+
- name: "KUBERNETES_CLUSTER_DOMAIN"
36+
value: {{.Values.global.cluster_domain}}
37+
{{- range $key, $value := .Values.grafana.environment }}
38+
- name: {{ $key }}
39+
value: {{ $value | quote }}
40+
{{- end }}
41+
- name: "DRYCC_GRAFANA_DOMAIN"
42+
value: http://drycc-monitor-grafana.{{ .Values.global.platform_domain }}
43+
- name: "DRYCC_PASSPORT_DOMAIN"
44+
value: http://drycc-passport.{{ .Values.global.platform_domain }}
45+
- name: "SOCIAL_AUTH_DRYCC_AUTHORIZATION_URL"
46+
value: "$(DRYCC_PASSPORT_DOMAIN)/oauth/authorize/"
47+
- name: "SOCIAL_AUTH_DRYCC_ACCESS_TOKEN_URL"
48+
value: "$(DRYCC_PASSPORT_DOMAIN)/oauth/token/"
49+
- name: "SOCIAL_AUTH_DRYCC_ACCESS_API_URL"
50+
value: "$(DRYCC_PASSPORT_DOMAIN)"
51+
- name: "SOCIAL_AUTH_DRYCC_USERINFO_URL"
52+
value: "$(DRYCC_PASSPORT_DOMAIN)/oauth/userinfo/"
53+
- name: SOCIAL_AUTH_DRYCC_GRAFANA_KEY
54+
valueFrom:
55+
secretKeyRef:
56+
name: passport-creds
57+
key: social-auth-drycc-grafana-key
58+
- name: SOCIAL_AUTH_DRYCC_GRAFANA_SECRET
59+
valueFrom:
60+
secretKeyRef:
61+
name: passport-creds
62+
key: social-auth-drycc-grafana-secret
63+
{{- end }}

charts/monitor/templates/monitor-grafana-deployment.yaml

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,10 @@ spec:
3636
memory: {{.Values.grafana.limits_memory}}
3737
{{- end}}
3838
{{- end}}
39-
env:
40-
{{- if eq .Values.global.influxdb_location "off-cluster" }}
41-
- name: "INFLUXDB_URL"
42-
valueFrom:
43-
secretKeyRef:
44-
name: influxdb-creds
45-
key: url
46-
{{- else }}
47-
- name: "INFLUXDB_URL"
48-
value: http://$(DRYCC_INFLUXDB_SERVICE_HOST):$(DRYCC_INFLUXDB_SERVICE_PORT_TRANSPORT)
49-
{{- end }}
50-
- name: "INFLUXDB_BUCKET"
51-
valueFrom:
52-
secretKeyRef:
53-
name: influxdb-creds
54-
key: bucket
55-
- name: "INFLUXDB_ORG"
56-
valueFrom:
57-
secretKeyRef:
58-
name: influxdb-creds
59-
key: org
60-
- name: "INFLUXDB_TOKEN"
61-
valueFrom:
62-
secretKeyRef:
63-
name: influxdb-creds
64-
key: token
65-
- name: "BIND_PORT"
66-
value: "3000"
67-
- name: "DEFAULT_USER"
68-
value: {{.Values.grafana.user}}
69-
- name: "DEFAULT_USER_PASSWORD"
70-
value: {{.Values.grafana.password}}
71-
- name: "KUBERNETES_CLUSTER_DOMAIN"
72-
value: {{.Values.global.cluster_domain}}
73-
{{- range $key, $value := .Values.grafana.environment }}
74-
- name: {{ $key }}
75-
value: {{ $value | quote }}
76-
{{- end }}
7739
ports:
7840
- containerPort: 3000
7941
name: ui
42+
{{- include "grafana.envs" . | indent 8 }}
8043
{{- if .Values.grafana.persistence.enabled }}
8144
volumeMounts:
8245
- name: grafana-data

grafana/rootfs/usr/share/grafana/grafana.ini.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,25 @@ enabled = true
226226
config_file = "/usr/share/grafana/ldap.toml"
227227
{{ end }}
228228

229+
#################################### Generic Oauth ##########################
230+
[auth.generic_oauth]
231+
{{ if .SOCIAL_AUTH_DRYCC_GRAFANA_KEY }}
232+
name = OAuth
233+
enabled = true
234+
client_id = {{ .SOCIAL_AUTH_DRYCC_GRAFANA_KEY }}
235+
client_secret = {{ .SOCIAL_AUTH_DRYCC_GRAFANA_SECRET }}
236+
scopes = profile,openid
237+
auth_url = {{ .SOCIAL_AUTH_DRYCC_AUTHORIZATION_URL }}
238+
token_url = {{ .SOCIAL_AUTH_DRYCC_ACCESS_TOKEN_URL }}
239+
api_url = {{ .SOCIAL_AUTH_DRYCC_USERINFO_URL }}
240+
allow_sign_up = true
241+
tls_skip_verify_insecure = true
242+
243+
[server]
244+
root_url = {{ .DRYCC_GRAFANA_DOMAIN }}
245+
246+
{{ end }}
247+
229248
#################################### SMTP / Emailing ##########################
230249
[smtp]
231250
{{ if .SMTP }}

0 commit comments

Comments
 (0)