superset: SECRET_KEY encrypts database secrets without warning, possibly breaking web interface if changed
Make sure these boxes are checked before submitting your issue - thank you!
- I have checked the superset logs for python stacktraces and included it here as text if any
- I have reproduced the issue with at least the latest released version of superset
- I have checked the issue tracker for the same issue and I haven’t found one similar
Superset version
0.20.4
Expected results
Usually, on web apps, app secrets are just used for generating cookies (see secrets.secret_key_base in Rails, SECRET_KEY in Django, or Wordpress security keys and salts), so you can happily use different ones for dev and production environments, or change them if you see fit or any of your configuration files has leaked. The only problem you’ll have is logged users will lose their session, but they can login again.
As Superset configuration doesn’t specify any other use for this secret, the expected result for changing this value would be losing connected sessions.
Actual results
- When accessing to any menu that connects so databases (e.g. a dashboard or a slice), we get a unicode exception, as in issues #2600 or #2966 .
- Then, if you figure out that’s not an Unicode error, but an encryption one, and you want to overwrite/change stored passwords on the Database Sources configuration, you’ll get a similar Unicode error, so, not being able to edit MySQL connections.
- Unless you manually edit the database, removing password blobs from connections, you won’t be able to do it.
Steps to reproduce
- Add a database source and or dashboard
- Change your SECRET_KEY in your config file
- Restart Superset
- Open a slice or dashboard
- EXCEPTION
Recommended fix behaviour
- Docs should WARN about backing up secret key (I can do that if docs are in source)
- Exception should be captured with a more obvious error
- Database Sources configuration menu should be accessible, also capturing the error and showing a message that passwords are not accessible, and allow overwriting that password with a new one that will be encoded with the new secret_key
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 25 (13 by maintainers)
Just got this error. Upgrading superset, got a warning that no
SECRET_KEYwas set, did set one, now everything broke. Great!EDIT: the warning should point to the documentation instead of suggesting setting a value without warning about database corruption.
It seems like there should at least be a warning if the secret key changes. I’d recommend this issue be re-opened so a warning can be added.
In the meantime, here is how I was able to fix this: https://github.com/apache/superset/issues/8538#issuecomment-922061313
Unfortunately, this bug is a time bomb 💣
i got an solution, add a config DB_SECRET_KEY in config.py it’s value is origin SECRET_KEY, then use config[“DB_SECRET_KEY”] replace config[“SECRET_KEY”] in superset/models/core.py Database model
So mine worked out. After changing the
SECRET_KEY, I went into superset and re-entered the database passwords sources>databases .database_engine://database_user:[database_password]@ip_address/database@mistercrunch when I add the
-dflag it does not pick up my local config, but when I remove it it does. see the output below (note the “loaded your LOCAL config” lines are missing in the debug output). Have also verified that the values are not present in the config, so it’s not just a logging thing:this is also an issue if you switch between debug mode and non-debug mode. debug mode seems to not load your
superset_config.pywhich means that if you start your server in one mode and then switch to the other you also get this error.is there a supported way to change your secret key if this happens?