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

FEATURE: Add setting for encryption key #3426

Open
wants to merge 1 commit into
base: 8.3
Choose a base branch
from

Conversation

christophlehmann
Copy link

@christophlehmann christophlehmann commented Dec 21, 2024

With this the encryption key can be defined in a setting. When defined it is not received from cache anymore.

Neos:
  Flow:
    security:
      cryptography:
        encryptionKey: 'something-random-usually-40-chars-long'

Ideally set this from an environment variable, so it doesn't have to be in your codebase…

Resolves: #3425

Upgrade instructions

None – but feel free to use the new feature. For existing projects, set the encryption key to the value found in the cache, Data/Persistent/Cache/Data/Flow_Security_Cryptography_HashService/encryptionKey usually.

Review instructions

Set the new setting to a non-empty string and see that \Neos\Flow\Security\Cryptography\HashService::generateHmac() returns a Hmac generated with your new encryption key.

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked with !!! and have upgrade-instructions

@kdambekalns
Copy link
Member

Usually we put the cache for this into the database, in case the filesystem does not suffice (e.g. if it's non-persistent or the setup scales over multiple server)…

Copy link
Member

@kdambekalns kdambekalns left a comment

Choose a reason for hiding this comment

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

I am not opposed to this. I wonder, though, if there should be some check for the key, to make sure it's not just 123 when it is set…

@christophlehmann
Copy link
Author

Plaintext secrets in the database might be a way, but have a bad touch to me.

wonder, though, if there should be some check for the key

Would keep it simple stupid. Its comment states the default length, which is sufficient in my eyes. Ok?

@kdambekalns
Copy link
Member

Plaintext secrets in the database might be a way, but have a bad touch to me.

True. Point taken.

Would keep it simple stupid. Its comment states the default length, which is sufficient in my eyes. Ok?

Yeah, fine. I guess anyone caring enough to set it, will do it right.

@kdambekalns kdambekalns changed the base branch from 7.3 to 8.3 January 28, 2025 21:46
@github-actions github-actions bot added 8.3 and removed 7.3 labels Jan 28, 2025
@kdambekalns kdambekalns changed the base branch from 8.3 to 7.3 January 28, 2025 21:47
@github-actions github-actions bot added 7.3 and removed 8.3 labels Jan 28, 2025
@kdambekalns
Copy link
Member

I tweaked the PR description a bit. It would be awesome if you could rebase this on Flow 8.3 though, as it's clearly not in scope for the security-only versions before that.

Oh, and – thanks for the PR! I don't mean to sound hostile. 😇

With this the encryption key can be defined in a setting:

Neos:
  Flow:
    security:
      cryptography:
        encryptionKey: 'something-random-usually-40-chars-long'

When defined it is not received from cache anymore.

Resolves: neos#3425
@christophlehmann christophlehmann force-pushed the f-3425-encryption-key-setting-73 branch from 209032e to f3ab6f4 Compare January 29, 2025 20:06
@christophlehmann christophlehmann changed the base branch from 7.3 to 8.3 January 29, 2025 20:07
@github-actions github-actions bot added 8.3 and removed 7.3 labels Jan 29, 2025
@christophlehmann
Copy link
Author

I tweaked the PR description a bit. It would be awesome if you could rebase this on Flow 8.3 though, as it's clearly not in scope for the security-only versions before that.

Okay, I interpreted 7.3 as lowest maintained branch. Is rebased!

I don't mean to sound hostile.

No, you don't. Questions and discussions are absolutely fine 👍

Copy link
Member

@kdambekalns kdambekalns left a comment

Choose a reason for hiding this comment

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

Ok, fine with me.

I requested review from a few people and have one last question (to those): In theory this must go into 8.4, as it is marked as a feature. But… is it? WDYT?

Copy link
Contributor

@dlubitz dlubitz left a comment

Choose a reason for hiding this comment

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

Thank you for your PR. This makes sence. I left one comment to discuss.

I'd rather vote for 8.4 but also fine with sneaking it into 8.3.

@@ -98,6 +98,10 @@ Neos:

cryptography:

# A private, unique key used for encryption tasks. Normally 40 characters long and received from a persistent
# filesystem cache. If set to a non-empty string, the cache is not involved anymore.
encryptionKey: ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it make sence to set this to null instead? Would clearly say, that this property is not set.

Suggested change
encryptionKey: ''
encryptionKey: null

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

Successfully merging this pull request may close these issues.

3 participants