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

feat(keys-rotation): manage cookie secret key #15296

Closed

Conversation

ofekisr
Copy link
Contributor

@ofekisr ofekisr commented Jun 22, 2021

SUMMARY

#15362 P2 implementaion, based on #15423

@ofekisr ofekisr changed the title Feat/keys management cookie [WIP] Feat/keys management cookie Jun 22, 2021
@amitmiran137 amitmiran137 changed the title [WIP] Feat/keys management cookie feat(keys-management) : manage cookie secret key Jun 22, 2021
@amitmiran137 amitmiran137 changed the title feat(keys-management) : manage cookie secret key feat(keys-mgmt) : manage cookie secret key Jun 22, 2021
@amitmiran137 amitmiran137 changed the title feat(keys-mgmt) : manage cookie secret key feat(keys-rotation) : manage cookie secret key Jun 24, 2021
@ofekisr ofekisr marked this pull request as ready for review June 24, 2021 18:13
@amitmiran137 amitmiran137 changed the title feat(keys-rotation) : manage cookie secret key feat(keys-rotation): manage cookie secret key Jun 24, 2021
@amitmiran137 amitmiran137 linked an issue Jun 24, 2021 that may be closed by this pull request
@apache apache deleted a comment from ofekisr Jun 24, 2021
@codecov
Copy link

codecov bot commented Jun 24, 2021

Codecov Report

Merging #15296 (4dc87f0) into master (2cb13e6) will decrease coverage by 0.29%.
The diff coverage is 17.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15296      +/-   ##
==========================================
- Coverage   76.96%   76.66%   -0.30%     
==========================================
  Files         976      979       +3     
  Lines       51296    51350      +54     
  Branches     6911     6911              
==========================================
- Hits        39478    39370     -108     
- Misses      11599    11761     +162     
  Partials      219      219              
Flag Coverage Δ
hive ?
mysql 81.47% <14.81%> (-0.14%) ⬇️
postgres 81.48% <17.85%> (-0.14%) ⬇️
presto ?
python 81.57% <17.85%> (-0.58%) ⬇️
sqlite 81.10% <14.81%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/initialization/secret_keys/__init__.py 0.00% <0.00%> (ø)
superset/initialization/secret_keys/consts.py 0.00% <0.00%> (ø)
...t/initialization/secret_keys/cookie_signing_key.py 0.00% <0.00%> (ø)
superset/initialization/__init__.py 87.05% <40.00%> (-0.87%) ⬇️
superset/app.py 63.38% <70.00%> (-0.12%) ⬇️
superset/config.py 97.04% <100.00%> (+0.01%) ⬆️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 69.44% <0.00%> (-17.07%) ⬇️
superset/db_engine_specs/presto.py 83.36% <0.00%> (-6.53%) ⬇️
superset/views/database/mixins.py 81.03% <0.00%> (-1.73%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cb13e6...4dc87f0. Read the comment docs.

# "single"
ENVIRONMENT_TYPE = os.environ.get("ENVIRONMENT_TYPE", "multithreaded")

COOKIE_SIGNING_KEY = os.environ.get("COOKIE_SIGNING_KEY", SECRET_KEY)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
COOKIE_SIGNING_KEY = os.environ.get("COOKIE_SIGNING_KEY", SECRET_KEY)
# it is also possible to use a lambda to load on every usage and change on the fly upon env var update like the following
# COOKIE_SIGNING_KEY = lambda: os.environ.get("COOKIE_SIGNING_KEY", SECRET_KEY)
COOKIE_SIGNING_KEY = os.environ.get("COOKIE_SIGNING_KEY", SECRET_KEY)

@dpgaspar dpgaspar requested a review from a team June 28, 2021 11:10
@ofekisr ofekisr force-pushed the feat/keys_management_cookie branch from a1015a6 to b500f19 Compare July 4, 2021 11:26
@ktmud
Copy link
Member

ktmud commented Jul 6, 2021

Please add PR description or convert this to a draft if not ready for review yet

Copy link
Member

@craig-rueda craig-rueda left a comment

Choose a reason for hiding this comment

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

Is this part of SIP 70? Should we wait for approval before this is merged?

@@ -0,0 +1,47 @@
# Licensed to the Apache Software Foundation (ASF) under one
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep init empty.

@@ -104,4 +107,12 @@ def load_override_config() -> Union[Dict[Any, Any], ModuleType]:


class SupersetApp(Flask):
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I agree with this pattern of hanging fields off of the App. A more widely accepted/established pattern is to use a custom extension that can be added to the Flask app via the extensions. We already have a mechanism for this (extensions.py)


from .cookie_signing_key import define_cookie_signing_key

if TYPE_CHECKING:
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Member

@craig-rueda craig-rueda left a comment

Choose a reason for hiding this comment

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

Also wondering if there's some overlap with the encrypted field manager I added a while back. I'd prefer if we merged the functionality in order to prevent duplication.

Lastly, I don't see any tests.

@ofekisr
Copy link
Contributor Author

ofekisr commented Jul 7, 2021

Also wondering if there's some overlap with the encrypted field manager I added a while back. I'd prefer if we merged the functionality in order to prevent duplication.

Lastly, I don't see any tests.

what you added is a specific concern - encryptedColumnFactory
here is totally different concern

@craig-rueda
Copy link
Member

Also wondering if there's some overlap with the encrypted field manager I added a while back. I'd prefer if we merged the functionality in order to prevent duplication.
Lastly, I don't see any tests.

what you added is a specific concern - encryptedColumnFactory
here is totally different concern

Sorta - They both deal with keys and the source of key material. I think it would be great to have a central secrets manager that can be easily overridden by orgs that want to extend functionality. Also, we have established patterns for this kinda stuff (app factory pattern) that should be followed here.

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

Successfully merging this pull request may close these issues.

[SIP-70] Secret keys rotations and stop using single SECRET_KEY
4 participants