-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve parsing of secret envs #296
Conversation
{{- if .Values.hydra.config.secrets.system -}} | ||
{{- $tmp := "" -}} | ||
{{- range .Values.hydra.config.secrets.system -}} | ||
{{- $tmp = printf "%s,'%s'" $tmp . -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will print single quotes around values? That is currently not properly parsed by hydra, see upstream PR ory/x#373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will print the supplied secrets as SECRETS_SYSTEM='foo bar 123 456 lorem','foo bar 123 456 lorem 1','foo bar 123 456 lorem 2','foo bar 123 456 lorem 3'
. It seems to be working aka, hydra is running and not complaining about them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it is not complaining but the secrets are now actually including the quote, therefore they are different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then hydra fails when trying to use those secrets later on for older records
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR
We have to use some csv encoding function here instead, that also properly escapes commas and double quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i think it makes the most sense, currently we force a string, which can be either a simple value or stringied json array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK not the best user experience though.
Why not
{{- define "hydra.secrets.system" -}}
{{- if .Values.hydra.config.secrets.system -}}
{{- if kindIs "[]string" .Values.hydra.config.secrets.system -}}
{{- mustToRawJson .Values.hydra.config.secrets.system -}}
{{- else -}}
{{- fail "Expected .Values.hydra.config.secrets.system to be a list of strings" -}}
{{- end -}}
{{- else if .Values.demo -}}
["a-very-insecure-secret-for-checking-out-the-demo"]
{{- end -}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also work, we just need to stringify at the end, as the result would be interpreted in bash [ string1 string2]
and hydra doesn't like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is up to you, I just think that it would be a bad user experience to put raw JSON into the yaml, instead of automatically encoding the yaml values when rendering the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to modify it slightly, but was able to make it work ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 😉
@aeneasr What do you think? |
Related issue(s)
Checklist
and signed the CLA.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got green light (please contact
security@ory.sh) from the maintainers to push
the changes.
works.
appropriate).
Further comments