Skip to content

Commit

Permalink
Add environment variables and log discovered values
Browse files Browse the repository at this point in the history
  • Loading branch information
Dougley committed Apr 1, 2024
1 parent 53cc96c commit d8096f7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/jwt-nginx-ext-auth/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.1
version: 0.0.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
21 changes: 13 additions & 8 deletions charts/jwt-nginx-ext-auth/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ spec:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
env:
- name: OIDC_DISCOVERY_URL
value: {{ .Values.oidcConfig.discoveryUrl }}
- name: JWKS_URI
value: {{ .Values.oidcConfig.jwksUri }}
- name: JWT_ISSUER
value: {{ .Values.oidcConfig.jwtIssuer }}
- name: JWT_AUDIENCE
value: {{ .Values.oidcConfig.jwtAudience }}
- name: JWT_HEADER
value: {{ .Values.oidcConfig.jwtHeader }}
- name: PORT
value: "{{ .Values.service.port }}"
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand All @@ -40,14 +53,6 @@ spec:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
Expand Down
7 changes: 7 additions & 0 deletions charts/jwt-nginx-ext-auth/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

oidcConfig:
discoveryUri: ""
jwksUri: ""
jwtIssuer: ""
jwtAudience: ""
jwtHeader: "authorization"

serviceAccount:
# Specifies whether a service account should be created
create: true
Expand Down
4 changes: 3 additions & 1 deletion src/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ if (process.env.OIDC_DISCOVERY_URI) {
jwks_uri: string;
issuer: string;
};
console.log("Discovered JWKS_URI", discoveryJson.jwks_uri);
console.log("Discovered issuer", discoveryJson.issuer);
process.env.JWKS_URI = discoveryJson.jwks_uri;
process.env.JWT_ISSUER = discoveryJson.issuer;
}
Expand All @@ -31,7 +33,7 @@ fastify.get<{
authorization: string;
};
}>("/", async (request, reply) => {
const header = process.env.JWT_HEADER ?? "authorization";
const header = (process.env.JWT_HEADER ?? "authorization").toLowerCase();
if (!request.headers[header]) {
reply.status(401).send({ error: "Unauthorized" });
return;
Expand Down

0 comments on commit d8096f7

Please sign in to comment.