kronhyx/session-bundle

Get online users and set rules

v0.7.1 2017-08-10 14:38 UTC

README

SessionBundle

SensioLabsInsight

SessionBundle Toolbar View

This bundle allows you to obtain all users connected to the system. In the same way it allows to define if the multi-session and the multi-user in the same is allowed.

Latest Stable Version Total Downloads Dependency Status Symfony License travis

Installation

Step 1: Download the Bundle

$ composer require kronhyx/session-bundle

This command requires that you have global composer installed, as explained in composer's documentation.

Step 2: Activate the Bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new \Kronhyx\SessionBundle\KronhyxSessionBundle()
        );
    }

    // ...
}

Step 3: Load the bundle routes

# app/config/routing.yml
kronhyx_session:
    resource: "@KronhyxSessionBundle/Resources/config/routing.yml"    
    prefix:   /
# ...

Step 4: Add the bundle configuration

# app/config/config.yml
kronhyx_session:
    provider: 'AppBundle:UserEntity'
    firewall: 'main'
    collector: true
    time:
        ajax: 5
        idle: 15
    allow:
        multi_session: true
        multi_user: true
    roles:
        - ROLE_SUPER_ADMIN        
# ...

Configuration:

  • provider (required): Represents the user provider entity that implement UserInterface
  • firewall: (default: main) Defines the name of the FIREWALL to which the security.yml rules belong
  • collector: (default: true) Defines whether to show the collector in the debug bar in _profiler
  • time.ajax: (default: 5)Time in seconds it takes to perform the next query that returns active sessions
  • time.idle: (default: 15)Time in seconds to define if a user is disconnected from the system
  • allow.multi_user: (default: true) Defines whether a user is allowed to have multiple active sessions on the same IP
  • allow.multi_session: (default: true) Defines whether a user is allowed to log in multiple times at the same time
  • roles.superadmin: (default: [ROLE_SUPER_ADMIN]) Defines which roles can end an active session

Step 5: Add a handler in the security.yml

# app/config/security.yml
# ...
firewalls:
    # ...
    form_login:
        # ...
        logout:
            handlers: [ Kronhyx\SessionBundle\Event\Listener\KernelListener ]
        # ...
    # ...

Step 6: Update Entities

$ php bin/console doctrine:schema:update --force 

Documentation

You can read all the documentation and functionalities of this bundle to make better use of this. !The documentation for this bundle is available in the Resources/doc directory of the bundle

Contributing

SessionBundle is a bundle for symfony framework, as it has been developed this has contributed a series of users that list here.

Security Issues

If you discover a vulnerability, a bug or have some idea to improve to propose that it leads to a better performance of this bundle, please contact us or leave your concerns here

Copyright

Copyright (c) 2017. See LICENSE for details.