diff --git a/CHANGELOG.md b/CHANGELOG.md index b9bf8765..c6a33be2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,9 +39,15 @@ ## 1.1.1 (Unreleased) +### Improvements + +* The API is now enabled by default and the API key -- if not yet set -- will be automatically generated on first + server start and written back into ``config.yaml`` + ### Bug Fixes * [#580](https://github.com/foosel/OctoPrint/issues/580) - Properly unset job data when instructed so by callers +* [IRC] Also allow downloading .g files via Tornado ## 1.1.0 (2014-09-03) @@ -115,4 +121,4 @@ ## 1.0.0 (2014-06-22) -First release with new versioning scheme. \ No newline at end of file +First release with new versioning scheme. diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 8197dfa5..8577f992 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -145,8 +145,8 @@ default_settings = { "subscriptions": [] }, "api": { - "enabled": False, - "key": ''.join('%02X' % ord(z) for z in uuid.uuid4().bytes), + "enabled": True, + "key": None, "allowCrossOrigin": False }, "terminalFilters": [ @@ -190,6 +190,10 @@ class Settings(object): self._configfile = os.path.join(self.settings_dir, "config.yaml") self.load(migrate=True) + if self.get(["api", "key"]) is None: + self.set(["api", "key"], ''.join('%02X' % ord(z) for z in uuid.uuid4().bytes)) + self.save(force=True) + def _init_settings_dir(self, basedir): if basedir is not None: self.settings_dir = basedir