2017 © Pedro Peláez
 

symfony-bundle debug-bundle

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

image

flying/debug-bundle

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  • Monday, August 8, 2016
  • by Flying
  • Repository
  • 1 Watchers
  • 0 Stars
  • 57 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 6 % Grown

The README.md

Debug bundle

This bundle provides several services that are mean to simplify developing process of Symfony 2 applications by emulating certain security related features in a case if request is running under debugger., (*1)

Debugger detection

Debugger detection is handled by DebuggerDetectorListener, Xdebug and Zend Debugger are recognized at this moment., (*2)

If some service needs to know if request is running under debugger - it should implement DebuggerStatusSubscriberInterface to get request status as soon as it will be determined., (*3)

CSRF token validation emulation

When debugging form submissions - it may be useful to disable CSRF token validation under debugger while having CSRF validation enabled., (*4)

CSRF token validation emulation is controlled by configuration:, (*5)

debug:
    csrf:
        # true to enable CSRF token validation emulation, false to disable it completely
        enabled: true
        # true to allow use of CSRF token validation emulation permanently, 
        # false to enable it only when running under debugger
        permanent: false
        # Status of emulated CSRF token validation
        token_validation_status: true

Unless enabled permanently - validation emulation is disabled automatically for production environment and can also be disabled in development environment. When enabled - it will substitute real CSRF validation with configured value if request was running under debugger. For normal requests all CSRF validation will be passed to real CSRF token manager unless use of emulation is forced by enabling permanent configuration option., (*6)

Debug authentication provider

Debug authentication provider can be used to transparently authenticate user that is required for debugging / development purposes. Example use case is debugging of some requests that are resides into secured area of application without need to hack application's configuration all the time (slow, boring and error prone)., (*7)

It is recommended to read Symfony book chapter about security and Symfony Cookbook recipe about custom authentication providers before using this feature., (*8)

Installation

To use debug authentication provider you're required to perform some changes into your code and configuration., (*9)

1. Create your own token builder

Security token is the key component of security in Symfony, you can read more about it here. Most of tasks related to creating custom authentication provider are handled by this bundle, but since token is too much specific for each particular application - it is your task to generate it. Luckily it is pretty easy. Token builder should implement TokenBuilderInterface, but you can also use AbstractTokenBuilder as a base in most cases. You need to implement build() method that receives Request object and needs to create and return security token, required for your application. Simplest implementation may look something like this:, (*10)

public function build(Request $request)
{
    // More about token configuration later
    $config = $this->getTokenConfig();
    $token = new UsernamePasswordToken($config['username'], '', 'debug', $config['roles']);
    return $token;
}

however real implementation may involve receiving user object from database or some other place. In a case if you use FOSUserBundle in your application - you may find it useful to inject their UserManager into class and take user from it., (*11)

Token builder can be used as a simple class, but it is preferable to register it as a service, especially if your token building logic depends on information from other services., (*12)

2. Register debug authentication provider

After implementing token builder you need to register debug authentication provider into your security configuration. Registration is explained here and may look like this:, (*13)

security:
    firewalls:
        main:
            pattern: ^/
            debug:
                token_builder: my.token_builder.service.id
            # Rest of your firewall definition

It is important to register debug authentication provider before real authentication providers that are used into your application so it will be able to provide debug security token generated by you and by this disable other security mechanisms., (*14)

3. Configure debug authentication provider

Debug authentication provider has following configuration options: - token_builder - Either service id or class name of your token builder. This option is required. - token_config - Arbitrary configuration information for your token builder. It is passed directly to your token builder via setTokenConfig method. For example you can pass username of user, you want to authenticate. - enabled - Allows you to completely disable or force this feature without any additional change. By default it is enabled for debug environments. - permanent - Set to true to enable user authentication substitution even if request is not running under debugger. May be useful for development purposes if you don't want to authenticate yourself all the time. Defaults to false meaning that debug authentication provider will only activate itself if request is running under debugger. - auth_provider and auth_listener options defines services of authentication provider and listener respectively and usually should not be changed., (*15)

The Versions

08/08 2016

dev-master

9999999-dev

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

10/09 2015

v0.2.7

0.2.7.0

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

06/10 2014

v0.2.6

0.2.6.0

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

25/09 2014

v0.2.5

0.2.5.0

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

25/09 2014

v0.2.4

0.2.4.0

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

26/06 2014

v0.2.3

0.2.3.0

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

21/06 2014

v0.2.2

0.2.2.0

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

21/06 2014

v0.2.1

0.2.1.0

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

19/06 2014

v0.2.0

0.2.0.0

Symfony 2 bundle to provide several tools to make it easier to use debugger with Symfony 2 applications

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

17/06 2014

v0.1.2

0.1.2.0

Small Symfony 2 bundle to disable CSRF token validation when running application under debugger

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

16/06 2014

v0.1.1

0.1.1.0

Small Symfony 2 bundle to disable CSRF token validation when running application under debugger

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky

12/06 2014

v0.1.0

0.1.0.0

Small Symfony 2 bundle to disable CSRF token validation when running application under debugger

  Sources   Download

MIT

The Development Requires

by Alexander Grimalovsky