2017 © Pedro Peláez
 

library simplecsrf

Simple CSRF-token class to prevent CSRF attacks. For forms and AJAX requests.

image

dimns/simplecsrf

Simple CSRF-token class to prevent CSRF attacks. For forms and AJAX requests.

  • Wednesday, February 7, 2018
  • by DimNS
  • Repository
  • 0 Watchers
  • 0 Stars
  • 154 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

Project is deprecated.

Simple CSRF-token class to prevent CSRF attacks

Latest Stable Version Total Downloads License, (*1)

Requirements

  • PHP 5.3 or higher is required.

Composer installation

  1. Get Composer.
  2. Require SimpleCSRF with php composer.phar require dimns/simplecsrf or composer require dimns/simplecsrf (if the composer is installed globally).
  3. Add the following to your application's main PHP file: require 'vendor/autoload.php';.

Usage with FORM

php, (*2)

getToken();

// Checking the token
if ($csrf->validateToken($_POST['_token'])) {
    echo 'Token correct';
} else {
    echo 'Invalid token';
}
```

html
```html

Usage with AJAX

php, (*3)

getToken();

// Checking the token
if ($csrf->validateToken($_SERVER['HTTP_X_CSRFTOKEN'])) {
    // Token correct
} else {
    // Invalid token
}
```

html
```html

    

javascript, (*4)

// jQuery
$.ajaxSetup({
    beforeSend: function (xhr, settings) {
        if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type)) {
            xhr.setRequestHeader("X-CSRFToken", $('meta[name="_token"]').attr('content'));
        }
    }
});

The Versions

07/02 2018

dev-master

9999999-dev http://github.com/dimns/simplecsrf

Simple CSRF-token class to prevent CSRF attacks. For forms and AJAX requests.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php csrf

25/07 2016

v2.0.0

2.0.0.0 http://github.com/dimns/simplecsrf

Simple CSRF-token class to prevent CSRF attacks. For forms and AJAX requests.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php csrf

28/06 2016

v1.0.0

1.0.0.0 http://github.com/dimns/simplecsrf

Simple CSRF-token class to prevent CSRF attacks

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php csrf