Security
In this section we are going to talk about security and how PHP Booster provide some helpers to prevent some attacks:
CRSF Attack
Is an attack that exploit forms request to search more about cross site request forgery visit: https://en.wikipedia.org/wiki/Cross-site_request_forgery
To avoid these type of attacks PHPBooster include a default set to protect from this attacks, but you could change it to false if you dont really take care about this type of protecction, you could change it in:
There you will find next code:
Please fill free to change all data to your personal information like Database information, Mail account and other Locale sets.
Its not recommendable is set by default but it´s possible to change it.
To use this protecction in all your forms, PHPBooster will obligate to set a crsf token, into every form you will need to add inside it the helper csrf_token_field()
Ex:
It will create a hidden input with the token, now you can send data to your controllers and all its going to run fine, but you could validate the data request to eval if the data goes from your app, in your controller you could use a helper to validate it as in the next example:
XSS Attack
To protect from scripting insertion PHPBooster provides helpers for frontend, backend and requests.
To clean a request in controllers you could use the helper:
As param you could send a $_POST or $_GET request or any other, it clean multiple types of inputs like Javascript and Querys insertion.
To print params in Views that are going to be encripted PHPBooster provide helpers to encript and decrypt fields:
You could print params of links or others with this helper to encript data, this helper generate encriptation dinamically so every project will automatically generate different encriptation, this helper support strings and integers so you could send a $_POST or $_GET method or create a variable to send as param.
To decript that information you could use the next helper:
To work you need to send as param the encripted field to decrypt it.
And if I want a encriptation without decrypt?
You could use the helper:
This could be useful with a login for example to validate that the request data match to some data from the database or to other variable you could use a simple and PHP native function:
In this particular case you could use it as:
SQL Injections
To protect to injections both BoosterQueryBuilder and BoosterORM create a bind query with PDO, you could send en every where method as second param value to bind or an array of values to bind.
for Ex:
In BoosterQueryBuilder:
In BoosterORM:
In both examples you will get a collection of objects, but the most important thing in this section is the way you could bind params just with "?", and send values as second param.
Last updated
Was this helpful?