You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for an issue that matches the one I want to file, without success.
I am not looking for support or already pursued the available support channels without success.
Version
2.29.0, main, doesn't matter
Storage Type
etcd
Installation Type
Binary
Expected Behavior
User can supply password (or other config via environment variable, while using DEX_EXPAND_ENV) in the config YAML, and the values would be safely converted into JSON.
Actual Behavior
Unmashaling JSON converted from connector YAML config fails:
=== RUN TestUnmarshalConfigWithEnvExpand config_test.go:445: failed to decode config: error unmarshaling JSON: parse connector config: invalid character 'd' after object key:value pair
=== RUN TestUnmarshalConfigWithEnvExpand config_test.go:445: failed to decode config: error unmarshaling JSON: parse connector config: invalid character 'd' after object key:value pair
The root cause is in function at cmd/dex/config.go:341. The call to os.ExpandEnv on L362 is unaware of the JSON context in which the variables are being expanded, and has a comment about it already. JSON enforces that values are enclosed in quotes, hence extra unescaped quotes or escape characters in the fields make the resulting JSON invalid.
Additional Information
These JSON illegal characters can appear in passwords, so the real use-case this came up was LDAP connector bindPW field. OIDC secret is used for reproduction as triggering it has a single line diff.
Configuration
config_test.go has the config.
Logs
=== RUN TestUnmarshalConfigWithEnvExpand
config_test.go:443: failed to decode config: error unmarshaling JSON: parse connector config: invalid character 'd' after object key:value pair
--- FAIL: TestUnmarshalConfigWithEnvExpand (0.00s)
The text was updated successfully, but these errors were encountered:
Since this is more or less known issue based on the comment in the code, it means you maintainers have probably an idea how it would be good to be fixed. Based on my debug conn.Config is a structure, so just checking up a keyname for bindPW and doing JSON illegal character replacing, but would at least need some sort of structure parsing etc, which feels hacky.
Let me know which solution would feel right here, I'll try fixing it!
Preflight Checklist
Version
2.29.0, main, doesn't matter
Storage Type
etcd
Installation Type
Binary
Expected Behavior
User can supply password (or other config via environment variable, while using DEX_EXPAND_ENV) in the config YAML, and the values would be safely converted into JSON.
Actual Behavior
Unmashaling JSON converted from connector YAML config fails:
Steps To Reproduce
config_test.go
:make test
with:Additional Information
These JSON illegal characters can appear in passwords, so the real use-case this came up was LDAP connector
bindPW
field. OIDC secret is used for reproduction as triggering it has a single line diff.Configuration
config_test.go has the config.
Logs
=== RUN TestUnmarshalConfigWithEnvExpand config_test.go:443: failed to decode config: error unmarshaling JSON: parse connector config: invalid character 'd' after object key:value pair --- FAIL: TestUnmarshalConfigWithEnvExpand (0.00s)
The text was updated successfully, but these errors were encountered: