You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Somehow... Fresh install broke after bringing container down and back up. Encryption key related. #4554
Clone the master git
Change needed values in the docker-compose.yml:
ports: 9000
ALLOWED_HOSTNAMES=[the ones I need]
Timezone: America/New_York
Force https: true
First Issue the readme file says to change the FORCE_HTTPS=false to FORCE_HTTPS=1 That does not work.
So I'm doing this because I'm putting this behind my own NPM setup. Everything is set up there. I get everything working there. We look good. I change my employee information. I setup a customer. I create an item. I make a sale to my customer. All is well.
I attempt to setup email. SMTP set for my gmail account I want to use. Everything is setup the way google tells me to set it up. Error on the screen when I say to send the receipt via email. Look for logs, nothing. I bring down the container and bring it back up just in case something needed to refresh or who knows what and boom, anywhere that I had information: mostly customers, items, and sales all get an error.
I moved to development so I could see the error and it is related to this:
SYSTEMPATH/Encryption/Encryption.php at line 133
I have been troubleshooting with ChatGPT to try to find what is not working or what may be missing and so far I have created a key and everything can see the key but the key does not seem to be coming into the /app/.env where it wants it to go.
Not sure what to do at this point in time. I can provide information as I continue to look through this. I would believe this is not expected behavior.
To fix that we generated a key and added the line to the docker-compose.yml file:
encryption.key: "hex2bin:[key here]"
But that did not work. Troubleshooting the error it looked like it was nearly every place except for /app/.env which is where it needed to be.
So we created /docker_volumes/ospos/config/.env then copied the current .env out to that location and then manually put the key in there in the encryption section where it says:
encryption.key = ''
and then added the line in the docker-compose.yml file in the volume section: /docker_volumes/ospos/config/.env:/app/.env
reloaded and it worked. ALMOST
From there Sales would not work and it turned out it was because of when I tried to setup and test email before all of this there was some kind of key that was used to encrypt the settings perhaps? We were getting "Authentication failed" error on the decryption when the sales module was loading the mail module.
The fix for that ended up being that now that we set the key and reloaded, I just went into the settings and saved the email password again. That overrode whatever it was looking for before with the new information that we have all the keys for.
All was well after that.
I have not tested email again to see WHAT was not working there. All I ever get is just a red message saying it cannot send it. I attempted to turn the logging level in the compose.yml file to 4 but that did nothing.
throttle.key — already supported today (checkThrottleEncryption() reads env('throttle.key') and returns it, no write)
In compose it's just an environment: entry. Note the outer .env that docker compose reads is a different file from the app's $ROOTPATH/.env — it lives on the host and never enters the container:
services:
ospos:
image: jekkos/opensourcepos:masterenvironment:
- ENCRYPTION_KEY=${ENCRYPTION_KEY:?set in the compose .env}
- throttle.key=${THROTTLE_KEY:?set in the compose .env}
openssl rand -hex 32 gives you both values.
Why not make ROOTPATH/.env writable just so the runtime can persist an auto-generated key:
.env holds long-lived secrets (the encryption key and the throttle key). The image currently keeps the app effectively read-only — only uploads/ and writable/logs are mounted in. Making the root writable so code can create/modify a file that contains secrets expands the mutable surface (a second container sharing that volume, a mis-permissioned mount, or a write-path traversal) to include those secrets.
Keeping secrets in the process environment, not the mutable filesystem, is the standard "no secrets in the image/filesystem" posture — and it's already what CI does here.
writable/ is the documented "safe to write" area for data. Mixing secret configuration into it (or forcing root to be writable) is a different kind of risk than data the app owns.
So the clean fix for #4554 is: ship the ENCRYPTION_KEY env var, document throttle.key on the image, and have docker compose set both. No .env writes, no shared key baked into the image, nothing to lose when the container is recreated — and no widening of the writable surface. This also unblocks #4656's concern about writing to .env in that environment.
Activity
jekkos commentedon May 21, 2026
Is there any applicatoon code on the stack trace? I can try to reproduce tonight
.are you using master docker?
Hallsie commentedon May 21, 2026
One moment... There were two issues. Let me hunt them down...
This was the initial one:
SYSTEMPATH/Encryption/Encryption.php : 133 — CodeIgniter\Encryption\Exceptions\EncryptionException::forNeedsStarterKey ()
126 }127128 if (! in_array($this->driver, $this->drivers, true)) {129 throw EncryptionException::forUnKnownHandler($this->driver);130 }131132 if (empty($this->key)) {133 throw EncryptionException::forNeedsStarterKey();134 }135136 $this->hmacKey = bin2hex(\hash_hkdf($this->digest, $this->key));137138 $handlerName = 'CodeIgniter\Encryption\Handlers' . $this->driver . 'Handler';139 $this->encrypter = new $handlerName($config);140SYSTEMPATH/Config/Services.php : 256 — CodeIgniter\Encryption\Encryption->initialize ( arguments )
To fix that we generated a key and added the line to the docker-compose.yml file:
encryption.key: "hex2bin:[key here]"
But that did not work. Troubleshooting the error it looked like it was nearly every place except for /app/.env which is where it needed to be.
So we created
/docker_volumes/ospos/config/.envthen copied the current .env out to that location and then manually put the key in there in the encryption section where it says:encryption.key = ''
and then added the line in the docker-compose.yml file in the volume section:
/docker_volumes/ospos/config/.env:/app/.envreloaded and it worked. ALMOST
From there Sales would not work and it turned out it was because of when I tried to setup and test email before all of this there was some kind of key that was used to encrypt the settings perhaps? We were getting "Authentication failed" error on the decryption when the sales module was loading the mail module.
The fix for that ended up being that now that we set the key and reloaded, I just went into the settings and saved the email password again. That overrode whatever it was looking for before with the new information that we have all the keys for.
All was well after that.
I have not tested email again to see WHAT was not working there. All I ever get is just a red message saying it cannot send it. I attempted to turn the logging level in the compose.yml file to 4 but that did nothing.
I hope all this helps.
Add decrypt_value() and encrypt_value() helper functions
Refactor all encryption/decryption to use helper functions
Address CodeRabbit feedback: validate key length, clarify encryption …
Address remaining CodeRabbit review comments
Fix encryption key persistence for Docker environments
Add fallback key loading from WRITEPATH in Encryption config
Handle encryption unavailability gracefully in controllers
Add encryption_failed error message to language file
Add decrypt_value() and encrypt_value() helper functions
Refactor all encryption/decryption to use helper functions
Address CodeRabbit feedback: validate key length, clarify encryption …
Address remaining CodeRabbit review comments
Fix encryption key persistence for Docker environments
5 remaining items
Address CodeRabbit feedback: validate key length, clarify encryption …
Address remaining CodeRabbit review comments
Fix encryption key persistence for Docker environments
Address reviewer comments: PSR compliance and code cleanup
Fix encryption key persistence for Docker environments
Add fallback key loading from WRITEPATH in Encryption config
Handle encryption unavailability gracefully in controllers
Add encryption_failed error message to language file
Fix encryption key persistence for Docker environments
Fix encryption key persistence for Docker environments
Fix encryption key persistence for Docker environments
jekkos commentedon Sep 7, 2026
Solution (no
.envwrites needed in Docker) — and why we shouldn't make.envwritable to "fix" this:Inject the secrets as env vars instead of writing them to the container's
.env. Both are already honored by the app:ENCRYPTION_KEY— newly supported in this branch (app/Config/Encryption.phpreads it as a fallback whenencryption.keyis empty), via fix(tests): resolve all phpunit failures — clean-DB suite green (#4626) #4691throttle.key— already supported today (checkThrottleEncryption()readsenv('throttle.key')and returns it, no write)In compose it's just an
environment:entry. Note the outer.envthatdocker composereads is a different file from the app's$ROOTPATH/.env— it lives on the host and never enters the container:openssl rand -hex 32gives you both values.Why not make
ROOTPATH/.envwritable just so the runtime can persist an auto-generated key:.envholds long-lived secrets (the encryption key and the throttle key). The image currently keeps the app effectively read-only — onlyuploads/andwritable/logsare mounted in. Making the root writable so code can create/modify a file that contains secrets expands the mutable surface (a second container sharing that volume, a mis-permissioned mount, or a write-path traversal) to include those secrets.writable/is the documented "safe to write" area for data. Mixing secret configuration into it (or forcing root to be writable) is a different kind of risk than data the app owns.So the clean fix for #4554 is: ship the
ENCRYPTION_KEYenv var, documentthrottle.keyon the image, and havedocker composeset both. No.envwrites, no shared key baked into the image, nothing to lose when the container is recreated — and no widening of the writable surface. This also unblocks #4656's concern about writing to.envin that environment.