Modify Entrypoint Script to Support Docker Secret for Admin Password#468
Modify Entrypoint Script to Support Docker Secret for Admin Password#468jj15asmr wants to merge 1 commit intoYOURLS:mainfrom
Conversation
|
Thanks for submitting this pull request, @jj15asmr. |
Thank you for the quick reply! Your point of fixing the upstream "bug" actually brings me back to something that confused me a bit when I was first investigating this problem, and is probably worth pointing out now: If my understanding is correct, the core The entrypoint script would appear to overlook this intention, though, by statically writing the contents of Basically, to me it seems that:
Assuming the core's intended behavior is the "correct" one to follow, shouldn't the entrypoint not write the username/password directly to the config file and instead allow it be determined dynamically at runtime using I hope that all makes sense 😅. If I am totally misunderstanding something here, then I apologize. |
The Problem
When supplying the admin password as a Docker (Compose) secret and using the
YOURLS_PASS_FILEenvironment variable to specify the path at which it is mounted in the container, automatic password hashing fails, and the following message is displayed in the admin panel:Could not auto-encrypt passwords. Error was: "preg_replace problem".It took me longer than I'd like to admit to trace it, but it appears to stem from the following part of the
container-entrypoint.shscript:containers/images/yourls/container-entrypoint.sh
Lines 77 to 82 in da022d5
It's checking if the
YOURLS_USERandYOURLS_PASSenvironment variables are both defined, and if so, overwriting the dynamic username/password array in the config file with their static values.YOURLS_PASSisn't defined when a secret is used for the password, and so this whole block isn't evaluated, causing the hashing process to fail as YOURLS can't actually find a match for the plaintext password in the config file.The (Proposed) Fix
The relevant chunk of the entrypoint script has been modified to also check for the
YOURLS_PASS_FILEenvironment variable. If filled in, the contents of the file are retrieved and set asYOURLS_PASS, allowing the config file to be edited as intended.