Skip to content

Commit

Permalink
changed the CLIENT_SECRET from the configEnv values property to a new…
Browse files Browse the repository at this point in the history
… secretsEnv values, and included it on a secret.yaml template, that can come from global.auth.clientSecret or from secretsEnv.clientSecret, also added a fallback that generates a random secret in case none is provided.

Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Apr 3, 2024
1 parent 1172355 commit f58e47d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
10 changes: 9 additions & 1 deletion charts/auth-layer-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ The following table lists the configurable parameters of the chart and their def
| `configEnv.ENVOY_ADMIN_PORT` | EnvoyProxy Configuration admin port | `15000` |
| `configEnv.PROXY_PORT` | EnvoyProxy Configuration proxy port | `10000` |
| `configEnv.CLIENT_ID` | OAuth Client ID, provided by the auth server | `htg-auth-layer` |
| `configEnv.CLIENT_SECRET` | OAuth Client Secret, provided by the auth server | `` |
| `configEnv.TOKEN_INTROSPECTION_URL` | OAuth Token Introspection URL, provided by the auth server | `http://host.docker.internal:8080/realms/HederaTheGraph/protocol/openid-connect/token/introspect` |
| `configSecrets.clientSecret` | OAuth Client Secret, provided by the auth server | `` |

Is also possible to use the global alternative to override `clientSecret` value, global has precendence over `configSecrets.clientSecret`, and if neither is provided a random 32 length value will be generated. Using the global alternative is useful when deploying multiple charts that share the same `clientSecret` value, otherwise, the `configSecrets.clientSecret` should be used.

Using the following command:
```bash
helm install <releaseName> . --set global.auth.clientSecret=your-client-secret
```


It is important to note that if the downstream service that we are protecting (in this case TheGraph) will be accessed by the proxy using a FQDN, the `SERVICE_TYPE` should be set to `LOGICAL_DNS` and the `SERVICE_ADDRESS` should be set to the FQDN of the service. Otherwise, if the downstream service is accessed by the proxy using an IP address, the `SERVICE_TYPE` should be set to `STATIC` and the `SERVICE_ADDRESS` should be set to the IP address of the service.
13 changes: 13 additions & 0 deletions charts/auth-layer-proxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Define a function to choose a value from .Values.global.auth.clientSecret, .Values.configSecrets.clientSecret, or generate a random string.
*/}}
{{- define "auth-layer-proxy.clientSecret" -}}
{{- if .Values.global.auth.clientSecret -}}
{{- .Values.global.auth.clientSecret -}}
{{- else if .Values.configSecrets.clientSecret -}}
{{- .Values.configSecrets.clientSecret -}}
{{- else -}}
{{- randAlphaNum 32 -}}
{{- end -}}
{{- end -}}
2 changes: 2 additions & 0 deletions charts/auth-layer-proxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ spec:
envFrom:
- configMapRef:
name: {{ include "auth-layer-proxy.fullname" . }}-env
- secretRef:
name: {{ include "auth-layer-proxy.fullname" . }}-secret
image: "{{ .Values.image.repository }}:{{ .Values.image.tagPrefix }}{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
livenessProbe:
Expand Down
6 changes: 6 additions & 0 deletions charts/auth-layer-proxy/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "auth-layer-proxy.fullname" . }}-secret
data:
CLIENT_SECRET: {{ include "auth-layer-proxy.clientSecret" . | b64enc }}
8 changes: 7 additions & 1 deletion charts/auth-layer-proxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ command: ["/etc/envoy/start-envoy.sh"]

configEnv:
CLIENT_ID: "htg-auth-layer"
CLIENT_SECRET: "2IfFX7eqQvg2wY2hh1qjtS8RrUY9YqEg"
ENVOY_ADMIN_PORT: "15000"
PROXY_PORT: "10000"
SERVICE_ADDRESS: "host.docker.internal"
SERVICE_PORT: "8020"
SERVICE_TYPE: "LOGICAL_DNS"
TOKEN_INTROSPECTION_URL: "http://host.docker.internal:8080/realms/HederaTheGraph/protocol/openid-connect/token/introspect"

configSecrets:
clientSecret: ""

fullnameOverride: ""

global:
auth:
clientSecret: ""

image:
pullPolicy: IfNotPresent
repository: ghcr.io/hashgraph/hedera-the-graph
Expand Down

0 comments on commit f58e47d

Please sign in to comment.