Skip to content
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

Allow secrets in settings #383

Merged
merged 1 commit into from
Oct 25, 2020

Conversation

TonyBrobston
Copy link
Contributor

@TonyBrobston TonyBrobston commented Oct 16, 2020

Fixes #371

Description of changes

Adds a secrets.json file and use mustache to render those secrets into settings.

Checklist

  • User-facing change description added to unreleased section of CHANGELOG.md
  • Update sampleConfiguration
  • Write higher level tests? Settings and main
  • Update Wiki?

@neilenns
Copy link
Owner

Cool! I'll take a look at it this weekend.

@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch 11 times, most recently from 372b966 to d209aaf Compare October 16, 2020 18:19
@TonyBrobston
Copy link
Contributor Author

Cool! I'll take a look at it this weekend.

Sounds good.

Copy link
Owner

@neilenns neilenns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! Just a few things here and there I noticed.

src/helpers.ts Outdated Show resolved Hide resolved
src/helpers.ts Outdated Show resolved Hide resolved
src/helpers.ts Outdated Show resolved Hide resolved
src/helpers.ts Outdated Show resolved Hide resolved
@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch 2 times, most recently from f5e732b to 0cbc3a7 Compare October 19, 2020 18:37
src/Settings.ts Outdated Show resolved Hide resolved
src/main.ts Outdated Show resolved Hide resolved
@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch 2 times, most recently from 2301f73 to e9a0525 Compare October 19, 2020 20:52
@TonyBrobston
Copy link
Contributor Author

@danecreekphotography I updated the sampleConfiguration. I think secrets should be used by default. I realize it is slightly more complicated, however I think it's not worth compromising security.

@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch 2 times, most recently from 8202504 to d91a01b Compare October 19, 2020 20:58
@neilenns
Copy link
Owner

The docker-compose.yaml change looks fine.

The settings.json file changes are a big hurdle for new users. Based on questions I've had here and elsewhere (ipcamtalk, other Facebook groups), most people using this don't understand Docker at all and just want to have their security cameras have AI motion. Even making minor changes to settings.json was a hurdle for some.

Adding another layer of indirection out of the box and having to explain all that in the documentation is probably overkill for the core userbase: people installing this at home on a home computer.

@TonyBrobston
Copy link
Contributor Author

The docker-compose.yaml change looks fine.

The settings.json file changes are a big hurdle for new users. Based on questions I've had here and elsewhere (ipcamtalk, other Facebook groups), most people using this don't understand Docker at all and just want to have their security cameras have AI motion. Even making minor changes to settings.json was a hurdle for some.

Adding another layer of indirection out of the box and having to explain all that in the documentation is probably overkill for the core userbase: people installing this at home on a home computer.

Gotcha. That makes sense and is an unfortunate reality.

I guess my use case is slightly different, I'm pushing my configuration to github (without secrets.json) so I have a copy, as well as source control. I try to set all my docker stuff up so I can re-image my ubuntu server if something goes haywire and just pull some configurations from github. It seems like users might want the ability to back their configuration up, however it sounds like the average user probably isn't familiar with github. I could see us building a UI that gets all this setup correctly on the backend, then follow home assistant's recommendation; I think they recommend backing things up to github. But like you said, this is probably a big hurdle for most.

I guess I'll just reap the benefits of this change; seems like others may not think to use this. I'll look around the docs and try to identify the right spot to add this information.

@neilenns
Copy link
Owner

Best place to add it to the docs would be as a whole new page called "Managing secrets". Then we can link to it from a bunch of places, like the overview documentation etc.

If you do write something up make sure to run markdownlint on the .md and resolve any errors that get thrown. Thanks!

@TonyBrobston
Copy link
Contributor Author

@danecreekphotography That sounds good to me. I'm not familiar with github's wiki, is that where you're wanting to put it? Is this just something you're able to edit or is there a way for me to fork it and push up a PR?

@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch from d91a01b to 93244dc Compare October 20, 2020 15:33
@neilenns
Copy link
Owner

Sure, if you ever have time and dig into it. I'm not going to look at it any time soon.

What's the overall status of this PR? Is there anything else you want to add before you consider it done?

@TonyBrobston
Copy link
Contributor Author

I've looked the PR over a few times and I can't think of anything else to add. Lmk if you're able to think of anything else.

I plan to follow this up with another PR which will handle secrets in triggers.json. Also, a side note so I don't forget; it's possible for secrets to be printed in logs accidentally, we'll want to be cognizant of this, since logging a secret will defeat the purpose of this work. I have some ideas on how to handle this or at a minimum, how to write a test that identifies the issue.

@TonyBrobston
Copy link
Contributor Author

Actually, it looks like I have something that will break triggers here: https://github.com/TonyBrobston/node-deepstackai-trigger/blob/93244dc5914965a7b49cb211bf961f003913daef/src/TriggerManager.ts#L53

So I need to do some work on that.

@TonyBrobston
Copy link
Contributor Author

I wonder if we should first put this out as a dev tag docker image. I'd hate to break the main docker image if I missed something.

@TonyBrobston
Copy link
Contributor Author

@neilenns
Copy link
Owner

neilenns commented Oct 20, 2020

When this eventually merges to main it will automatically become a dev tag image. The latest image is a manual release by me so there's no risk of having people auto-update until it's really published as stable.

What I've done in the past is produce a separate tagged image for a specific branch. That might be the best thing to do here too: merge this into another branch instead of main, then run it for a bit as that image off Docker Hub before actually merging to main as dev.

@TonyBrobston
Copy link
Contributor Author

I'm good with a separate tag for a specific branch or going to dev, totally up to you.

I was looking into allowing secrets in triggers, it looks super similar to allowing secrets in settings. I think the only thing I'm wondering is, some naming on the object that holds the settingsFilePath and secretsFilePath. I currently have IConfiguration. However I now need another object that holds triggersFilePath and secretsFilePath. So I'm thinking of moving IConfiguration to ISettingsConfiguration and then adding a ITriggersConfiguration. However, we have some other types that are very close to those names: ISettingsConfigJson and ITriggersConfigJson. What are your thoughts? I think I'll go ahed and push my changes up. So my previous comment is slightly incorrect; I'll follow this PR up with another PR that handles removing secrets from a few areas that log, I'm not sure what that looks like yet.

@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch 3 times, most recently from 45d73d7 to ad752c6 Compare October 20, 2020 19:58
@neilenns
Copy link
Owner

Since IConfiguration isn't really the configuration, it's the paths to the configuration files, maybe do ISettingsFiles? Also why does it have to be a different interface for settings vs triggers? Just call it IConfiguration and have the properties be baseFile and secretsFile?

@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch from ad752c6 to e5f5879 Compare October 20, 2020 20:16
@TonyBrobston
Copy link
Contributor Author

Alright, I updated to what you mentioned.

@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch 2 times, most recently from 79ae9f8 to 57f02d0 Compare October 20, 2020 20:40
@TonyBrobston
Copy link
Contributor Author

Looking into how to handle redacting secrets from logs and I realized I had broken triggers.json hot reloading. I made some changes to hopefully fix that.

@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch 4 times, most recently from bf013d5 to e575c46 Compare October 20, 2020 21:06
@neilenns
Copy link
Owner

I created a new branch called issue371. Can you either change this PR to point at that (does GitHub allow that?) or close this PR and open a new one requesting to merge into that branch instead of main?

That'll give us a place to merge this and produce the Docker tagged image for testing without having it show up in main until we're confident this is all working and ready to go out.

@TonyBrobston TonyBrobston changed the base branch from main to issue371 October 22, 2020 01:39
@TonyBrobston
Copy link
Contributor Author

@danecreekphotography I swapped the branch that it's merging into.

@TonyBrobston TonyBrobston force-pushed the mustache-template-settings branch from e575c46 to 49588bc Compare October 22, 2020 13:35
@neilenns neilenns merged commit 00894bc into neilenns:issue371 Oct 25, 2020
neilenns pushed a commit that referenced this pull request Oct 31, 2020
neilenns pushed a commit that referenced this pull request Nov 6, 2020
* Allow secrets in settings (#383)

* Fix uri encoding (#385)

* Fix mustache render url test (#387)

* Allow secrets in settings (#383)

* Fix uri encoding (#385)

* Fix mustache render url test (#387)

* Update changelog with security patch

Co-authored-by: Tony Brobston <[email protected]>
@davkav
Copy link

davkav commented Aug 31, 2021

Just got caught about by this. Can a sample secrets.json be included in the sampleConfiguration directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

triggerUri exposes plain text Blue Iris Username and Password
3 participants