2017 © Pedro Peláez
 

library csrf-api-unprotection-bundle

Disables the CSRF-token validation for all urls that matches a given expression.

image

dkplus/csrf-api-unprotection-bundle

Disables the CSRF-token validation for all urls that matches a given expression.

  • Friday, May 4, 2018
  • by [-UFO-]Melkor
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,950 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 8 % Grown

The README.md

CSRF API Unprotection Bundle

Build Status Scrutinizer Code Quality Code Coverage Dependency Status HHVM Status Latest Stable Version Latest Unstable Version SensioLabsInsight, (*1)

When developing stateless REST-APIs you do not want to CSRF token validation. Fortunately FOSRest provides the ability to disable it., (*2)

The solution does not work if you do not have a ROLE for all API users., (*3)

This Bundle disables the CSRF token validation based upon the URL of the request. So if your API has a global prefix like /api/ you can disable the CSRF token validation for all your API forms., (*4)

Installation

Step 1: Download the Bundle

Installation of this Bundle uses composer. It requires you to have Composer installed globally. For composer documentation, please refer to getcomposer.org., (*5)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*6)

composer require dkplus/csrf-api-unprotection-bundle

Step 2: Enable the Bundle within your AppKernel

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:, (*7)

<?php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // …

            new Dkplus\CsrfApiUnprotectionBundle\DkplusCsrfApiUnprotectionBundle,
        );

        // …
    }

    // …
}

That's everything you need :-), (*8)

Configuration

The default configuration disables the CSRF token validation for all uris that begins with /api/ regardless which environment you are using., (*9)

dkplus_csrf_api_unprotection:
    rules:
        match_uri:
            - "#^(/app(_[a-zA-Z]*)?.php)?/api/#"

The Versions

04/05 2018
31/05 2016
31/05 2016
08/10 2015

v1.1.0

1.1.0.0

Disables the CSRF-token validation for all urls that matches a given expression.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2015

v1.0.1

1.0.1.0

Disables the CSRF-token validation for all urls that matches a given expression.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2015

v1.0

1.0.0.0

Disables the CSRF-token validation for all urls that matches a given expression.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2015

v0.1

0.1.0.0

Disables the CSRF-token validation for all urls that matches a given expression.

  Sources   Download

MIT

The Requires

 

The Development Requires