S
|
sfuente 6/8/2024 |
Yes, your concern is valid. Storing the MySQL connection string in a file like Here are some recommendations to improve the security of your application:
By implementing these practices, you can minimize the risk of your database connection details being misused by unauthorized individuals. |
M
|
MikeT 6/9/2024 |
you can store (and I would recommend it) outside the webroot and import them in the ConnectionsManager, like it's done in an .env file in other frameworks. $DatabaseAccess = parse_ini_file('PATH TO YOUR CRED-FILE"); And in your cred-file write down the above variables and values. Finally remove the connection setting you stored before and do a clean rebuild, at least if you're using the same credentials. |
P
|
PK author 6/9/2024 |
Thank you sfuente. Great tips. I will explore SSL/TLS route. @MikeT, I like your solution. Just a few questions:
So the cred-file will have: Thanks again |
M
|
MikeT 6/9/2024 |
I think this should be in the official documentation, hope they'll put it there some day. It won't give you absolute security of course (you e.g. still have to take care on who has access to your server etc.), and there's a lot of (philosophical) discussion around this, but IMO it's just good practice to do it like that for a live/exposed application. |
P
|
PK author 6/11/2024 |
Im sorry mikeT, but Im still a little lost. The import code (the stuff I gave an example of) goes into the setting in phprunner where you put in the db credentials This is where I put my db credentials and I dont see how I put this code there $DatabaseAccess = parse_ini_file('PATH TO YOUR CRED-FILE"); Could you please dumb it down for me |
M
|
MikeT 6/11/2024 |
In the Tab "Output" in the section "server database connections". Then create a file that you will store outside the webroot, call it what you want, e.g. prod_db.ini [database] you need to make sure that the path you give to parse_ini_file is correct, i.e. is the path to the location of your the file you've stored outside the webroot. Also: if you want to prevent that the credentials show up in the ConnectionManager, delete the preset you used before in "server database connections" and do a clean rebuild. |
P
|
PK author 6/12/2024 |
mikeT,
So I tried deleting it directly from the ConnectionsManager.php file but then the app wont load anymore. So with the old connection still in there Im not sure if the new connection I created is being used
And when you say do a "clean" build, what exacly is that Thanks again |
M
|
MikeT 6/12/2024 |
The default settings will be the ones you enter on the first screen in phprunner when you begin your project. These default credentials will always be in the output, but if they're for a local database and different from production credentials, it's no problem. Clean build: Just a full build. |
P
|
PK author 6/13/2024 |
Got it. Solved! |