-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support environment variables in config.yml #23
Comments
Thank you! I'm so glad you're enjoying it! I've looked around and I can't find a crate for my specific use case that doesn't have a lot of additional bloat to do what you described with the environment variables. That said, I can easily implement it manually and thanks to Rust's type system, it wouldn't be security vulnerability. But before I even do that, I wanted to ask: What's the use case for doing this? Docker images I'm guessing? Otherwise, it seems like it would be more useful to support predefined environment variables (e.g. Would that be preferable? To just allow environment variable overrides/exclusive environment variable configs? Or is there a greater need for defining arbitrary environment variables within the YAML that I've just never encountered? |
Simply because I don't like leaving passwords lying around in plaintext, even if it's low risk. If we can set the environment variables globally and do it that way that also works. It just seemed to me that from a consistency standpoint (and ease of use for less advanced users) that keeping everything in the config file would make more sense. Either method is fine by me, honestly. |
Hmm...I know that this is a pretty standard pattern (thinking of things like kubeconfigs), but I do think an argument could be made for only the API keys as environment variables. Seems like that could work too. Alternatively, if you use a password manager at all, you could theoretically just save the entire config as a password and use that with process substitution to start Managarr; i.e. something like managarr --config <(some-pass-manager show managarr-config) I've not tried using process substitution with the |
Regarding API keys in the config file, I'll admit that I'm also not a huge fan, despite it, admittedly, being a pretty common practice. Drawing from the comparison with kubeconfigs that you mentioned, @Dark-Alex-17, I can think of two ways that this concern could be mitigated:
#\2 would probably be more involved than supporting base64-encoded values, but I'd also prefer to have a way to avoid keys existing in my config files at all, if possible. If you'd like, I can take a shot at implementing either approach and putting together a PR for it 😄 Lmk if you'd find either or both of those approaches to be acceptable. |
I see no good reason not to add that functionality since it is technically more secure. However, my naive implementation of this is to parse the YAML file and replace all What are you thinking? Oh, and for easy reference, this is the code to load the config YAML 😄 : pub(super) fn load_config(path: &str) -> Result<AppConfig> {
let file = File::open(path).map_err(|e| anyhow!(e))?;
let reader = BufReader::new(file);
let config = serde_yaml::from_reader(reader)?;
Ok(config)
} |
Thanks for the pointers! Originally, yes, I was thinking what you suggested: do a sort of find-and-replace in the YAML values, but it didn't feel as clean as making config deserializers would. I took a shot at doing that in #30. I'm not fully sure of what, if anything, would need to be done to protect against any sort of command injection attacks. My initial thought is that as long as we're not evaluating or executing what's in the environment variable values, we should be safe? But we could probably add some tests to feel more confident about that. |
I hope you don't mind me pushing to your branch. I tried to think of a better way to share the changes I was playing with but it was too many to leave in comments. |
Not at all 😁 I'm checking the changes locally now. |
It doesn't seem like the YAML parser you're using supports environment variable expansion.
How difficult would it be to implement this?
Granted, my arrs are not publicly exposed, but I do store my dotfiles on GitHub, and I'd prefer not to have my API keys for them stored there for anyone to see.
Being able to load them from a .env file or system wide environment variables would be a nice enhancement.
Something like this:
I just started playing with this today, nice little project! :)
The text was updated successfully, but these errors were encountered: