Cms: FR: Ability to store plugin license keys in .env file

Created on 11 Jun 2019  路  8Comments  路  Source: craftcms/cms

Description

For security reasons, it would be nice to be able to keep my plugin licenses stored in my .env files and out of the project.yaml file in my repo. Currently it's only possible to have the license defined explicitly in the project config file.

Most helpful comment

@jurriaanr Thanks for pointing that out. Just removed the maxlength input attribute for today鈥檚 3.2.6 release.

All 8 comments

This is possible with the CRAFT_LICENSE_KEY PHP constant.

.env:

LICENSE_KEY="#########..."

web/index.php (after loading .env):

define('CRAFT_LICENSE_KEY', getenv('LICENSE_KEY'));

This is possible with the CRAFT_LICENSE_KEY PHP constant.

For the Craft license sure, but I was talking about specific 3rd party plugin licenses.

Sorry, somehow I missed that!

Just added the ability to set plugin license keys to environment variables using the $VARIABLE_NAME syntax, for the next release. If you do, they will be saved to your project.yaml file the same way, so the license key won鈥檛 make it into your repo.

Fantastic, thank you!

Small problem with this is that the name of the variable has a max length because the field is cut to the length of a license key

@jurriaanr Thanks for pointing that out. Just removed the maxlength input attribute for today鈥檚 3.2.6 release.

For those interested in storing the license key in an environment variable: don't forget to add define('CRAFT_LICENSE_KEY', getenv('LICENSE_KEY')); also to the /craft executable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mccombs picture mccombs  路  3Comments

benface picture benface  路  3Comments

angrybrad picture angrybrad  路  3Comments

bitboxfw picture bitboxfw  路  3Comments

RitterKnightCreative picture RitterKnightCreative  路  3Comments