Skip to content

Commit

Permalink
jwt auth support added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Canpolat Oral committed Dec 2, 2024
1 parent 01493cb commit bd395ee
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/apps/account/values-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ base-ms-chart:
authorizationPolicy:
enabled: true

allowedSources:
allowedServiceAccounts:
- namespace: transfer
serviceAccount: transfer-service
- namespace: istio-system
Expand Down
23 changes: 21 additions & 2 deletions charts/base/base-ms-chart/templates/authorizationpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,29 @@ spec:
app.kubernetes.io/name: {{ include "ms.name" . }}
action: ALLOW
rules:
{{- range .Values.authorizationPolicy.allowedSources }}
{{- range .Values.authorizationPolicy.allowedServiceAccounts }}
- from:
- source:
# namespaces: ["{{ .namespace }}"]
principals: ["cluster.local/ns/{{ .namespace }}/sa/{{ .serviceAccount }}"]
to:
- operation:
{{- if .methods }}
methods: {{ .methods | toYaml | nindent 8 }}
{{- end }}
{{- if .paths }}
paths: {{ .paths | toYaml | nindent 8 }}
{{- end }}
{{- end }}
{{- range .Values.authorizationPolicy.allowedClients }}
- from:
- source:
principals: ["{{ .issuer }}/{{ .clientId }}"]
to:
{{- if .methods }}
methods: {{ .methods | toYaml | nindent 8 }}
{{- end }}
{{- if .paths }}
paths: {{ .paths | toYaml | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/base/base-ms-chart/templates/requestauthentication.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.requestAuthentication.enabled }}
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name: {{ include "ms.fullname" . }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "ms.name" . }}
jwtRules:
{{- range .Values.requestAuthentication.jwtRules }}
- issuer: "{{ .issuer }}"
jwksUri: "{{ .jwksUri }}"
{{- end }}
{{- end }}
16 changes: 13 additions & 3 deletions charts/base/base-ms-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

mtls:
peerAuthentication:
enabled: false


# mtls:
# mode: STRICT

# mode: STRICT

requestAuthentication:
enabled: false

# jwtRules:
# - issuer: https://auth.example.com
# jwksUri: https://auth.example.com/.well-known/jwks.json

virtualService:
enabled: false

Expand Down Expand Up @@ -56,7 +66,7 @@ destinationRule:
authorizationPolicy:
enabled: false

# allowedSources:
# allowedServiceAccounts:
# - namespace: transfer
# serviceAccount: transfer-service-account
# - namespace: customer
Expand Down

0 comments on commit bd395ee

Please sign in to comment.