usefulteam / jwt-auth

WordPress JSON Web Token Authentication
https://wordpress.org/plugins/jwt-auth/
122 stars 48 forks source link

Add environment variable support #65

Open sviluppomania opened 2 years ago

sviluppomania commented 2 years ago

The JWT_AUTH_SECRET_KEY as well as JWT_AUTH_CORS_ENABLE can be read from environment variables instead of hardcoding in wp-config.php

sun commented 2 years ago

You can put the following lines into your wp-config.php to not hardcode them:

define('JWT_AUTH_SECRET_KEY', $_ENV['JWT_AUTH_SECRET_KEY'] ?? '');
define('JWT_AUTH_CORS_ENABLE', $_ENV['JWT_AUTH_CORS_ENABLE'] ?? '');

This has the benefit that you are explicitly documenting which constants are being read from environment variables in your setup.