Skip to content
Snippets Groups Projects
Commit 551a026b authored by Arie Peterson's avatar Arie Peterson
Browse files

Merge branch '41-make-oauth2-client-data-persistent-2' into 'master'

Resolve "Make oAuth2 Client data persistent"

See merge request openappstack/single-sign-on!25
parents 8a3bc3d5 0202efea
No related branches found
No related tags found
1 merge request!25Resolve "Make oAuth2 Client data persistent"
Pipeline #3786 passed with stages
in 3 minutes and 23 seconds
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ include "single-sign-on.fullname" . }}-recreate-oauth2-clients
labels:
{{ include "single-sign-on.labels" . | indent 4 }}
spec:
schedule: "*/5 * * * *"
jobTemplate:
metadata:
labels:
app.kubernetes.io/managed-by: {{.Release.Service | quote }}
app.kubernetes.io/instance: {{.Release.Name | quote }}
helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
spec:
template:
spec:
restartPolicy: Never
containers:
{{- range .Values.oAuthClients }}
- name: {{ .clientName | quote }}
image: {{ $.Values.userbackend.image.repository }}:{{ $.Values.userbackend.image.tag }}
imagePullPolicy: {{ $.Values.userbackend.image.pullPolicy }}
env:
- name: CLIENT_ID
valueFrom:
secretKeyRef:
name: oauth2-clients
key: {{ .clientName }}_client_id
- name: CLIENT_SECRET
valueFrom:
secretKeyRef:
name: oauth2-clients
key: {{ .clientName }}_client_secret
- name: CLIENT_NAME
value: {{ .clientName | quote }}
- name: REDIRECT_URI
value: {{ .redirectUri | quote }}
- name: SCOPES
value: {{ .scopes | quote }}
- name: CLIENT_URI
value: {{ .clientUri | quote }}
- name: CLIENT_LOGO_URI
value: {{ .clientLogoUri | quote }}
- name: TOKEN_ENDPOINT_AUTH_METHOD
value: {{ .tokenEndpointAuthMethod | quote }}
- name: RESPONSE_TYPES
value: "{{- range .responseTypes }}\"{{ . }}\",{{- end }}"
- name: GRANT_TYPES
value: "{{- range .grantTypes }}\"{{ . }}\",{{- end }}"
command: ["/bin/bash", "-c"]
args:
- >
curl http://{{ $.Release.Name }}-hydra-admin:4445/health/ready \
--silent \\
--write-out "\nCheck Hydra health: HTTP %{http_code}" \
| tail -1 | grep 200 && echo "Hydra is ready to accept requests." &&
curl http://{{ $.Release.Name }}-hydra-admin:4445/clients/$CLIENT_NAME \
--silent \
--write-out "\nRequesting oauth client $CLIENT_NAME: HTTP %{http_code}\n" \
| tail -1 \
| grep 404 &&
curl --header "Content-Type: application/json" \
--request POST \
--data "{\"client_id\": \"$CLIENT_ID\",
\"client_name\": \"$CLIENT_NAME\",
\"client_secret\": \"$CLIENT_SECRET\",
\"client_uri\": \"$CLIENT_URI\",
\"logo_uri\": \"$CLIENT_LOGO_URI\",
\"redirect_uris\": [\"$REDIRECT_URI\"],
\"scope\": \"$SCOPES\",
\"grant_types\": [$GRANT_TYPES\"\"],
\"response_types\": [$RESPONSE_TYPES\"\"],
\"token_endpoint_auth_method\": \"client_secret_post\"}" \
http://{{ $.Release.Name }}-hydra-admin:4445/clients \
--silent \
--write-out "\nCreating oauth client $CLIENT_ID: HTTP(%{http_code})\n" \
| tail -1 \
| grep 201 &&
echo "Successfully created $CLIENT_ID"
{{- end }}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment