REG-22125 fix standalone-generated AES-256 EncryptionKey length#7
Open
echerry-rs wants to merge 1 commit into
Open
REG-22125 fix standalone-generated AES-256 EncryptionKey length#7echerry-rs wants to merge 1 commit into
echerry-rs wants to merge 1 commit into
Conversation
Generate the EncryptionKey and JWTSecretKey from a base64url-safe alphabet (A-Za-z0-9-_, no '=' or '+') using the `secrets` module, and size the EncryptionKey at exactly 32 UTF-8 bytes so Encryptor.cs's AES-256 check (which compares raw UTF-8 byte length to 32) passes. A pre-write validator asserts the EncryptionKey byte length so a regression here fails the setup step rather than the platform startup. Also: update the startup-detection string to match the log line the current platform actually emits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes REG-22125: standalone setup produced a 64-byte EncryptionKey, which fails the AES-256 check in
Atlas.Utilities/Helpers/Encryptor.cs(The encryption key must encode to exactly 32 bytes for AES-256. Got 64 bytes.).generate_key(length)usessecrets.choiceover the base64url alphabet excluding=and+(A-Za-z0-9-_), satisfying the ticket's request for an env-var-safe, cross-platform-safe key format.EncryptionKeyis now 32 chars / 32 UTF-8 bytes (AES-256).JWTSecretKeyis also 32 chars (>= 256 bits for HS256)._assert_aes_key_lengthvalidator runs before the key is written, so a regression failssetuprather than platform startup.Note on the underlying mismatch (see ticket comment)
The ticket asks for the value to be base64-encoded and decode to 32 bytes, but the runtime path that produces this error (
Encryptor.cs) does not base64-decode -- it counts raw UTF-8 bytes. The newerSecureKeyService.ValidateAndParseKeydoes decode and validate correctly; aligningEncryptor.cswith that pattern is a worthwhile platform-side follow-up so on-prem and SaaS truly agree on key format.Test plan
=or+.standalone_regscale.py setupagainst a clean install dir; confirmatlas.envEncryptionKey=value is exactly 32 chars and that the resulting container starts without the AES-256 length error.