Skip to content

Commit 809278c

Browse files
authored
Merge pull request #16 from holaplex/espi/hub-gateway-0.3.0
[Hub Gateway] CORS, Internal Service, and X-User-Email
2 parents 8784670 + ba6f4c6 commit 809278c

File tree

5 files changed

+58
-11
lines changed

5 files changed

+58
-11
lines changed

charts/hub-gateway/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type: application
1818
# This is the chart version. This version number should be incremented each time you make changes
1919
# to the chart and its templates, including the app version.
2020
# Versions are expected to follow Semantic Versioning (https://semver.org/)
21-
version: "0.2.2"
21+
version: "0.3.0"
2222

2323
# This is the version number of the application being deployed. This version number should be
2424
# incremented each time you make changes to the application. Versions are not expected to

charts/hub-gateway/plugins/kratos.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,18 @@ function _M.access(conf, ctx)
155155
end
156156

157157
-- Expose user id on $kratos_user_id variable
158+
-- Expose user email on $kratos_user_email variable
158159
if conf.expose_user_id then
159160
core.request.set_header(ctx, "x-user-id", data.identity.id)
160161
core.response.set_header("x-user-id", data.identity.id)
162+
core.request.set_header(ctx, "x-user-email", data.identity.traits.email)
163+
core.response.set_header("x-user-email", data.identity.traits.email)
161164
core.ctx.register_var("kratos_user_id", function(ctx)
162165
return data.identity.id
163166
end)
167+
core.ctx.register_var("kratos_user_email", function(ctx)
168+
return data.identity.traits.email
169+
end)
164170
end
165171
end
166172

charts/hub-gateway/templates/apisixroute.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- $apisixPlugins := .Values.apisixPlugins -}}
22
{{- $namespace := .Values.hubNamespace -}}
3-
{{- $domain:= .Values.domain -}}
3+
{{- $domain := .Values.domain -}}
44
{{- $sessionCookie := .Values.sessionCookieName -}}
55
{{- with .Values.routes }}
66
{{- range . }}
@@ -20,16 +20,12 @@ spec:
2020
websocket: {{ .websocket | default false }}
2121
match:
2222
hosts:
23-
- {{ print .subdomain "." $domain | quote }}
23+
- {{ .host | default (printf "%s.%s" .subdomain $domain) | quote }}
2424
paths:
25-
{{ .paths | toYaml | nindent 7 }}
25+
{{- .paths | toYaml | nindent 8 }}
2626
methods:
27-
{{ .methods | toYaml | nindent 7 }}
27+
{{- .methods | toYaml | nindent 8 }}
2828
plugins:
29-
{{- if .cors }}
30-
- name: cors
31-
enable: true
32-
{{- end }}
3329
{{- if .setUserHeader }}
3430
- name: kratos
3531
enable: true
@@ -44,7 +40,7 @@ spec:
4440
enable: true
4541
config:
4642
regex_uri:
47-
{{ .regexUri | toYaml | nindent 9 }}
43+
{{- .regexUri | toYaml | nindent 10 }}
4844
{{- end }}
4945
---
5046
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: apisix-gateway-internal
5+
labels:
6+
{{- include "hub-gateway.labels" . | nindent 4 }}
7+
spec:
8+
type: ClusterIP
9+
ports:
10+
- port: 80
11+
targetPort: 9080
12+
protocol: TCP
13+
name: http
14+
selector:
15+
app.kubernetes.io/instance: hub-gateway
16+
app.kubernetes.io/name: apisix

charts/hub-gateway/values.yaml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,34 @@ routes:
1313
methods:
1414
- POST
1515
- OPTIONS
16-
cors: true
16+
setUserHeader: true
17+
regexUri:
18+
- "/graphql"
19+
- "/"
20+
21+
- name: api-internal
22+
serviceName: federated-router
23+
servicePort: 80
24+
host: apisix-gateway-internal.ingress-apisix.svc.cluster.local
25+
paths:
26+
- /graphql
27+
methods:
28+
- POST
29+
- OPTIONS
30+
setUserHeader: true
31+
regexUri:
32+
- "/graphql"
33+
- "/"
34+
35+
- name: hub-browser-graphql
36+
serviceName: federated-router
37+
servicePort: 80
38+
subdomain: hub
39+
paths:
40+
- /graphql
41+
methods:
42+
- POST
43+
- OPTIONS
1744
setUserHeader: true
1845
regexUri:
1946
- "/graphql"
@@ -44,6 +71,8 @@ routes:
4471
- /organizations/new
4572
- /projects
4673
- /projects/*
74+
- /treasuries
75+
- /treasuries/*
4776

4877
- name: ui-public
4978
subdomain: hub

0 commit comments

Comments
 (0)