-
Notifications
You must be signed in to change notification settings - Fork 89
How to use
CSRFP can be easily used to create a new web application or integrated with existing one! Here is step by step guide on integrating CSRFP with an existing web application in php
, similar logic will apply while creating a new one.
You can download the library's latest release from here
Now let us assume you have downloaded and placed the library in root directory of your web application. We are also assuming that you have an index.php
file.
You'd definitely want to include the library at the beginning of the php file, as CSRFP behaves like an interceptor, you'd want CSRFP logic be implemented before any web application logic. So include the library like:
<?php
include_once __DIR__ .'/libs/csrf/csrfprotector.php';
Now that you have included the library only task left is to activate it in your page. In the simplest form you can call the library like
include_once __DIR__ .'/libs/csrf/csrfprotector.php';
//Initialise CSRFGuard library
csrfProtector::init();
This will cause library to pick up configurations from the config file and perform the validation and modification.
You can also call init()
with parameters for different page specific behaviour. Read our documentation on this
PS: wiki still under development. Please create a Github issue for any correction.